void RunMsg(OP code) { switch (code) { case OP.CMSG_AUTH_SESSION: // CMSG_AUTH_SESSION { if (LogMessageEvent != null) { LogMessageEvent("CMSG_AUTH_SESSION build=" + inPacket.Seek(2).GetWord()); } Seek(6).Get(out userName); pendAuth = new Hashtable(); pendAuth["Name"] = userName; pendAuth["Hash"] = this.GetHashCode(); pendAuth["Retry"] = (int)0; ServerGroup.Send(ServerGroupMessageType.UserQuery, pendAuth); SetTimeoutFunction("CMSG_AUTH_SESSION", 500, new TimerFunction(CheckAuth)); } break; case OP.CMSG_PING: Send(OP.SMSG_PONG, Seek(2).GetArray(4)); break; default: { DoMessageFunction h = handler[code] as DoMessageFunction; if (h == null) { gameServer.LogMessage("UNKNOWN OP: ", code.ToString(), (ushort)code, inPacket.Length); Send(OP.MSG_NULL_ACTION, new byte[] { 0, (byte)code, (byte)((ushort)code >> 8) }); } else { h(code, this); } break; } } }
public void AddHandler(OP code, DoMessageFunction h, object ob) { handler[code] = h; handlerob[code] = ob; }