Now most of GGSChat uses the GGS protocol both ways

This commit is contained in:
Jonatan Pålsson 2011-02-28 12:56:23 +01:00
parent 9ff48a90b3
commit 6986bc269f
4 changed files with 64 additions and 17 deletions

View file

@ -1,5 +1,5 @@
-module(ggs_protocol).
-export([parse/1, getToken/1]).
-export([parse/1, getToken/1, create_message/4]).
%% API Functions
parse(Data) ->
@ -14,6 +14,18 @@ getToken(Parsed) ->
false
end.
create_message(Cmd, Enc, Acc, Data) ->
Length = integer_to_list(string:len(Data)),
Msg = "Client-Command: " ++ Cmd ++ "\n" ++
"Client-Encoding: " ++ Enc ++ "\n" ++
"Content-Size: " ++ Length ++ "\n" ++
"GGS-Version: 1.0\n" ++
"Accept: " ++ Acc ++ "\n" ++
"\n" ++
Data,
Msg.
%% Internal helpers
do_parse(Data, ParsedMessage) ->
NewLinePos = string:chr(Data, $\n),