Some futher work on flib net client part qmlfrontend
authorunc0rr
Wed, 22 Apr 2015 23:33:16 +0300
branchqmlfrontend
changeset 10898 f373838129c2
parent 10896 5a74923120d5
child 10900 6a805e822074
Some futher work on flib net client part
hedgewars/uFLIPC.pas
hedgewars/uFLNet.pas
tools/protocolParser.hs
--- a/hedgewars/uFLIPC.pas	Thu Apr 16 23:31:13 2015 +0300
+++ b/hedgewars/uFLIPC.pas	Wed Apr 22 23:33:16 2015 +0300
@@ -10,6 +10,7 @@
 procedure freeIPC;
 
 procedure ipcToEngine(s: shortstring);
+procedure ipcToEngineRaw(p: pointer; len: Longword);
 //function  ipcReadFromEngine: shortstring;
 //function  ipcCheckFromEngine: boolean;
 
@@ -85,6 +86,16 @@
     ipcSend(msg, msgFrontend, mutFrontend, condFrontend)
 end;
 
+procedure ipcToEngineRaw(p: pointer; len: Longword);
+var msg: TIPCMessage;
+begin
+    msg.str[0]:= #0;
+    msg.len:= len;
+    msg.buf:= GetMem(len);
+    Move(p^, msg.buf^, len);
+    ipcSend(msg, msgEngine, mutEngine, condEngine)
+end;
+
 procedure ipcToFrontendRaw(p: pointer; len: Longword);
 var msg: TIPCMessage;
 begin
--- a/hedgewars/uFLNet.pas	Thu Apr 16 23:31:13 2015 +0300
+++ b/hedgewars/uFLNet.pas	Wed Apr 22 23:33:16 2015 +0300
@@ -11,15 +11,22 @@
 
 var sock: PTCPSocket;
     fds: PSDLNet_SocketSet;
+    buf: shortstring;
+
+function netReader(data: pointer): LongInt; cdecl; export;
+begin
+end;
 
 procedure connectOfficialServer;
 var ipaddr: TIPAddress;
 begin
-    if sock <> nil then 
+    if sock <> nil then
         exit;
 
     if SDLNet_ResolveHost(ipaddr, PChar('netserver.hedgewars.org'), 46631) = 0 then
-        sock:= SDLNet_TCP_Open(ipaddr)
+        sock:= SDLNet_TCP_Open(ipaddr);
+
+    callbackListenerThread:= SDL_CreateThread(@listener{$IFDEF SDL2}, 'ipcListener'{$ENDIF}, nil);
 end;
 
 procedure initModule;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/protocolParser.hs	Wed Apr 22 23:33:16 2015 +0300
@@ -0,0 +1,29 @@
+module Main where
+
+import Text.PrettyPrint.HughesPJ
+
+data HWProtocol = Command String [CmdParam]
+data CmdParam = Skip
+              | SS
+              | LS
+              | IntP
+              | Many [CmdParam]
+data ClientStates = NotConnected
+                  | JustConnected
+                  | ServerAuth
+                  | Lobby
+
+cmd = Command
+cmd1 s p = Command s [p]
+cmd2 s p1 p2 = Command s [p1, p2]
+
+commands = [
+        cmd "CONNECTED" [Skip, IntP]
+        , cmd1 "NICK" SS
+        , cmd1 "PROTO" IntP
+        , cmd1 "ASKPASSWORD" SS
+        , cmd1 "SERVER_AUTH" SS
+        , cmd1 "LOBBY:JOINED" $ Many [SS]
+    ]
+
+main = undefined