static void MsgLogout(UserCenter self, Message msg) { if (!(msg.Param is string)) { return; } self._users.Remove((string)msg.Param); }
static void MsgSavePacket(UserCenter self, Message msg) { if (!(msg.Param is string)) { return; } self._db.SavePacket(msg.Param as byte[]); }
static void MsgLoadPacket(UserCenter self, Message msg) { ArrayList al = msg.Param as ArrayList; if (al == null) { return; } CardPeer peer = al[0] as CardPeer; uint revision = (uint)al[1]; FileRecord file = self._db.LoadPacket(revision); Message ret = new Message((byte)CardPeer.MessageCodes.MSG_LOAD_PACKET_RESULT); ret.Param = file; peer.SendMessage(ret); }
static void MsgLogin(UserCenter self, Message msg) { if (!(msg.Param is ArrayList)) { return; } ArrayList al = (ArrayList)msg.Param; if (al.Count < 3) { return; } CardPeer peer = (CardPeer)al[0]; string usr = (string)al[1]; string pwd = (string)al[2]; GameUser user = null; if (self._users.ContainsKey(usr)) { user = self._users[usr]; } else { user = self._db.ValidateUser(usr, pwd); if (user != null) { self._users.Add(usr, user); } else if (log.IsDebugEnabled) // user not found { log.Debug(string.Format("User not found: name={0}, pwd={1}", usr, pwd)); } } Message ret = new Message((byte)CardPeer.MessageCodes.MSG_LOGIN_RESULT); ret.Param = user; peer.SendMessage(ret); }