public void HandlerPackage(JSNPackageIn pkg) { if (pkg == null) { log.Error("Package can not null!"); return; } int code = pkg.Code; IPackageHandler handler = null; if (m_packagesHandlers.ContainsKey(code)) { handler = m_packagesHandlers[code]; } else { log.ErrorFormat("Receive package's code is not exists! Code: {0}", code); log.Error(Marshal.ToHexDump(string.Format("Code: {0}", code), pkg.Buffer)); } if (handler == null) return; long timeUsed = Environment.TickCount; try { handler.HandlePacket(m_client, pkg); } catch (Exception ex) { string ep = m_client.Socket.RemoteEndPoint; log.ErrorFormat("Error while processing package (handler={0} RemoteEndPoint={1})", handler.GetType().FullName, ep); log.Error("Handle package error!", ex); } timeUsed = Environment.TickCount - timeUsed; log.InfoFormat("Package process time: {0}ms", timeUsed); if (timeUsed > 1000) { string source = m_client.Socket.RemoteEndPoint; log.WarnFormat("({0}) Handle package thread {1} {2} took {3}ms!", source, System.Threading.Thread.CurrentThread.ManagedThreadId, handler, timeUsed); } }
public int HandlePacket(GameClient client, JSNPackageIn pkg) { Console.WriteLine("{3}, {0}, {1}, {2}", pkg.readInt(), pkg.readUTF(), pkg.readInt(), pkg.readShort()); for (int i = 0; i < 80; i++) { JSNPackageIn p = new JSNPackageIn(2048); p.Code = 990; p.writeInt(i); p.writeUTF("服务端测试包"); //p.writeShort((short)i); client.SendOut.SendTCP(p); } return 0; }
public void SendTCP(JSNPackageIn pkg) { }
public void SendTCP(JSNPackageIn pkg) { m_connector.SendPkg(pkg); }
public void SendTCP(JSNPackageIn pkg) { m_gameClient.SendTcp(pkg); }
public void SendTCP(JSNPackageIn pkg) { m_serverClient.SendTcp(pkg); }