// on login private void _handleAuthResponse(WorldPack pack) { string account = ""; pack.R(ref account); Console.WriteLine("login accout {0} success;", account); }
bool HandleSysPack(WorldPack pack) { Debug.Log("SystemPack Start"); if (!pack.isSystem) { return(false); } short type = 0; Int16 param = 0; pack.R(ref type); Debug.Log("SystemPack " + type.ToString()); switch (type) { case SYS_PACKET_KEEP_ALIVE: pack.R(ref param); // Sys_Log("recv keep alive msg"); byte p1 = 1; WorldPack pk = new WorldPack(); pk.W(SYS_PACKET_ALIVE_ACK); pk.W(param); pk.W(p1); gcOutPacket(pk, true); break; case SYS_PACKET_ALIVE_ACK: pack.R(ref param); // Sys_Log("recv alive ack msg"); m_rtt = Time.time - (float)param / 1000.0f; break; case SYS_PACKET_SET_SEED: { pack.R(ref param); SetSeed(param); ConnectWorkFinish(true); } break; default: return(false); } return(true); }
private void _handleCharList(WorldPack pack) { UInt16 size = 0; pack.R(ref size); for (int i = 0; i < size; i++) { _handleAddChar(pack); } }
private void _handleAddChar(WorldPack pack) { UInt16 id = 0; string name = ""; bool male = true; UInt16 race = 0; UInt16 lv = 0; pack.R(ref id); pack.R(ref name); pack.R(ref male); pack.R(ref race); pack.R(ref lv); // add this char to your elder list. string str = String.Format(" Add char id = {0},name = {1}, is {2}, race is {3},lv is {4}", id, name, male?"男":"女", race, lv); Debug.Log(str); }
private void _handlePong(WorldPack pack) { UInt32 rec_ping = 0; UInt32 now = (UInt32)DateTime.UtcNow.Millisecond; pack.R(ref rec_ping); if (rec_ping != _ping) { Console.WriteLine("sending : we look for get ping: {0},but get ping: {1} on time: {2}" , _ping , rec_ping , now); _pinAck = true; return; } _latencey = (UInt32)(now - _lastPing); _pinAck = true; }
private void _handleRPC(WorldPack pack) { //receive if (false == enable) { Debug.LogWarning("RPC: we stoped rpc ,waiting for resume"); packs.Add(pack); return; } UInt32 prams = 0; pack.R(ref prams); string methodName = ""; pack.R(ref methodName); string des = methodName; des += "("; List <object> pramList = new List <object>(); int count = 0; UInt32 type = (prams >> (3 * count) & 7); while (type != 0) { switch (type) { case LUA_TBOOLEAN: { Boolean value = false; pack.R(ref value); pramList.Add(value); des += value.ToString(); des += " , "; } break; case LUA_TUSERDATA: { Int64 value = 0; pack.R(ref value); pramList.Add(value); des += "[Int64]"; des += value.ToString(); des += " , "; } break; //case LUA_TTHREAD: // { // UInt64 value = 0; // pack.R(ref value); // pramList.Add(value); // des += value.ToString(); // des += " , "; // } // break; case LUA_TBNUMBER: { Int32 value = 0; pack.R(ref value); pramList.Add(value); des += "[Int32]"; des += value.ToString(); des += " , "; } break; case LUA_TSTRING: { string value = ""; pack.R(ref value); pramList.Add(value); des += "[String]"; des += value.ToString(); des += " , "; } break; default: { Debug.LogWarning("RPC: callClientMethod Got unknown data type methods"); } break; } count++; type = (prams >> (3 * count) & 7); } des += " ) "; if (methodName != "a") { Log("S-> " + des); } _callClientMethod(methodName, pramList); }