private static void Recv() { var ss = socket.GetAvailableBytes(); if (ss > hdrSize) { var response = new ServerMessage(socket); GD.Print("recv << cmd:", response.cmd, " data:", response.data); var handler = Core.HandlerManager.GetHandler(response.cmd); if (handler != null) { var err = handler.Run(response.data); if (err != null) { Dbg.LogErr("Handler error: ", err); } } } }
private static void Send(NET_CMD cmd, JSONNode data) { var jData = CreateRequest(cmd, seq, UserId, CurToken, data); var bData = jData.ToString().ToUTF8(); var bufferSize = hdrSize + bData.Length; var buffer = new byte[bufferSize]; uint offset = 0; offset += Utilites.PushIntBE(buffer, bData.Length, offset); offset += Utilites.PushUShortBE(buffer, (ushort)cmd, offset); offset += Utilites.PushUShortBE(buffer, seq, offset); offset += Utilites.PushByteLE(buffer, bData, offset); var status = socket.PutData(buffer); Dbg.Log("send >> status:", status, " data: ", jData); seq++; }
public override void _Ready() { // Runtime DB Init var err = DB.Init(); if (err != null) { Dbg.LogErr("DB Init: ", err); return; } Dbg.LogSucc("DB Init: Success!"); // Game Handlers Init err = HandlerInit(); if (err != null) { Dbg.LogErr("Handler Init: ", err); return; } Dbg.LogSucc("Handlers Init: Success!"); // Entity Manager Init err = EntityManager.Init(); if (err != null) { Dbg.LogErr("Entity Manager Init: ", err); return; } Dbg.LogSucc("Entity Manager Init: Success!"); // TCP Client ClientTCP.Init(installToken, headerSize); err = ClientTCP.AuthOnServer(authIP, authPort); if (err != null) { Dbg.LogErr("Auth Failed: ", err); return; } Dbg.LogSucc("Auth Success"); }