1.¿Í»§¶Ë·¢Ë͵ǽÏûÏ¢
private void button_login_Click(object sender, EventArgs e) { this.selfID = this.textBox_ID.Text.Trim(); LoginMsg loginMsg = new LoginMsg(this.selfID); this.tcpPassiveEngine.PostMessageToServer(loginMsg.ToContractStream()); }
View Code2.·þÎñ¶Ë»Ø¸´µÇ½ÏûÏ¢
1 if (msgType == MsgType.Logining) 2 { 3 LoginMsg loginMsg = MsgHelper.DeserializeMsg<LoginMsg>(msg); 4 this.ReplyLogining(loginMsg, userAddress); .TellOtherUser(MsgType.NewOnlineFriend, loginMsg.SrcUserID); 7 } »Ø¸´µÇ½ÏûÏ¢ ReplyLogining(LoginMsg loginMsg, IPEndPoint userAddress) 15 { { 18 loginMsg.LogonResult = LogonResult.Repetition; 19 this.tcpServerEngine.SendMessageToClient(userAddress, loginMsg.ToContractStream()); 20 } { 23 this.AddUser(loginMsg.SrcUserID, userAddress); 24 this.ShowOnlineUserCount(); 25 loginMsg.LogonResult = LogonResult.Succeed; 26 this.tcpServerEngine.SendMessageToClient(userAddress, loginMsg.ToContractStream()); 27 } 28 }
View Code3.¿Í»§¶Ë´¦ÀíµÇ½½á¹û
tcpPassiveEngine_MessageReceived(IPEndPoint userAddress, byte[] msg) 2 { msgType = BitConverter.ToInt32(msg, 0); (msgType == MsgType.Logining) 7 { 8 LoginMsg loginMsg = MsgHelper.DeserializeMsg<LoginMsg>(msg); 9 if (loginMsg.LogonResult == LogonResult.Succeed) 10 { 11 this.DialogResult = DialogResult.OK; 12 this.tcpPassiveEngine.MessageReceived -= new StriveEngine.CbDelegate<IPEndPoint, byte[]>(tcpPassiveEngine_MessageReceived); 13 } 14 if (loginMsg.LogonResult == LogonResult.Repetition) 15 { ); 17 } 18 } 19 }
View Code Îå·¿Í»§¶Ë»¥ÏàÁÄÌìµÄͨÐŹý³Ì
¡¡