Add some real messages to ASN.1 and handle pings on server
This commit is contained in:
@@ -23,13 +23,14 @@ handle_cast(_Msg, State) ->
|
||||
|
||||
handle_info({ssl, Socket, Data}, State) ->
|
||||
case 'StudySystemProtocol':decode('Request', Data) of
|
||||
{ok, {foo, _}} ->
|
||||
{ok, Encoded}
|
||||
= 'StudySystemProtocol':encode('Response', {msg, "Foo"}),
|
||||
{ok, {ping, _}} ->
|
||||
{ok, Encoded} = 'StudySystemProtocol':encode(
|
||||
'Response', {ack, 'NULL'}),
|
||||
ok = ssl:send(Socket, Encoded);
|
||||
Result ->
|
||||
io:format("Invalid message: ~p~n", [Result]),
|
||||
ok
|
||||
{error, {asn1, _Reason}} ->
|
||||
{ok, Encoded} = 'StudySystemProtocol':encode(
|
||||
'Response', {error, invalidRequest}),
|
||||
ok = ssl:send(Socket, Encoded)
|
||||
end,
|
||||
{noreply, State};
|
||||
handle_info({ssl_closed, _Socket}, State) ->
|
||||
|
||||
Reference in New Issue
Block a user