public void PacketArrived(LumaQQ.NET.Packets.InPacket inPacket) { // BasicInPacket packet = (BasicInPacket)inPacket; if (inPacket is UnknownInPacket) { client.PacketManager.OnReceivedUnknownPacket(new QQEventArgs <UnknownInPacket, OutPacket>(client, (UnknownInPacket)inPacket, null)); return; } if (inPacket is ErrorPacket) { ErrorPacket error = (ErrorPacket)inPacket; if (error.ErrorType == ErrorPacketType.ERROR_TIMEOUT) { client.PacketManager.OnSendPacketTimeOut(new QQEventArgs <InPacket, OutPacket>(client, null, error.TimeOutPacket)); } else { client.OnError(new QQEventArgs <ErrorPacket, OutPacket>(client, (ErrorPacket)inPacket, null)); } return; } // 检查目前是否已经登录 if (user == null || !user.IsLoggedIn) { //按理说应该把在登陆之前时收到的包缓存起来,但是在实际中观察发现,登录之前收到的 //东西基本没用,所以在这里不做任何事情,简单的抛弃这个包 if (!IsPreloginPacket(inPacket)) { return; } } // 现在开始判断包的类型,作出相应的处理 ConnectionPolicy policy = client.ConnectionManager.GetConnection(inPacket.PortName).Policy; // 根据输入包,检索对应的输出包 OutPacket outPacket = policy.RetrieveSent(inPacket); // 这里检查是不是服务器发回的确认包 // 为什么要检查这个呢,因为有些包是服务器主动发出的,对于这些包我们是不需要 // 从超时发送队列中移除的,如果是服务器的确认包,那么我们就需要把超时发送队列 // 中包移除 switch (inPacket.Command) { // 这三种包是服务器先发出的,我们要确认 case QQCommand.Recv_IM: case QQCommand.Recv_Msg_Sys: case QQCommand.Recv_Msg_Friend_Change_Status: break; // 其他情况我们删除超时队列中的包 default: client.PacketManager.RemoveResendPacket(inPacket); client.PacketManager.OnSendPacketSuccessed(new QQEventArgs <InPacket, OutPacket>(client, inPacket, outPacket)); break; } switch (inPacket.Command) { case QQCommand.Request_Login_Token: this.user = client.QQUser; ProcessRequestLoginTokenReply((RequestLoginTokenReplyPacket)inPacket, outPacket as RequestLoginTokenPacket); break; case QQCommand.Login: ProcessLoginReply((LoginReplyPacket)inPacket, outPacket as LoginPacket); break; case QQCommand.Keep_Alive: ProcessKeepAliveReply((KeepAliveReplyPacket)inPacket, outPacket as KeepAlivePacket); break; case QQCommand.Recv_IM: ProcessReceiveIM((ReceiveIMPacket)inPacket); break; case QQCommand.Get_Friend_List: ProcessGetFriendListReply((GetFriendListReplyPacket)inPacket, outPacket as GetFriendListPacket); break; case QQCommand.Get_Online_OP: ProcessGetFriendOnlineReply((GetOnlineOpReplyPacket)inPacket, outPacket as GetOnlineOpPacket); break; case QQCommand.Get_UserInfo: ProcessGetUserInfoReply((GetUserInfoReplyPacket)inPacket, outPacket as GetUserInfoPacket); break; case QQCommand.Change_Status: ProcessChangeStatusReply((ChangeStatusReplyPacket)inPacket, outPacket as ChangeStatusPacket); break; case QQCommand.Recv_Msg_Friend_Change_Status: ProcessFriendChangeStatus((FriendChangeStatusPacket)inPacket); break; case QQCommand.Recv_Msg_Sys: ProcessSystemNotification((SystemNotificationPacket)inPacket); break; case QQCommand.Add_Friend_Ex: ProcessAddFriendExReply((AddFriendExReplyPacket)inPacket, outPacket as AddFriendExPacket); break; case QQCommand.Add_Friend_Auth: ProcessAddFriendAuthReply((AddFriendAuthResponseReplyPacket)inPacket, outPacket as AddFriendAuthResponsePacket); break; case QQCommand.Remove_Self: ProcessRemoveSelfReply((RemoveSelfReplyPacket)inPacket, outPacket as RemoveSelfPacket); break; case QQCommand.Delete_Friend: ProcessDeleteFriendReply((DeleteFriendReplyPacket)inPacket, outPacket as DeleteFriendPacket); break; case QQCommand.Authorize: ProcessAuthorizeReply((AuthorizeReplyPacket)inPacket, outPacket as AuthorizePacket); break; case QQCommand.Upload_Group_Friend: ProcessUploadGroupFriendReply((UploadGroupFriendReplyPacket)inPacket, (UploadGroupFriendPacket)outPacket); break; case QQCommand.Modify_Info: ProcessModifyInfoReply((ModifyInfoReplyPacket)inPacket, (ModifyInfoPacket)outPacket); break; case QQCommand.Signature_OP: ProcessSignatureOpReply((SignatureOpReplyPacket)inPacket, (SignatureOpPacket)outPacket); break; case QQCommand.Privacy_Data_OP: ProcessPrivacyDataOpReply((PrivacyDataOpReplyPacket)inPacket, (PrivacyDataOpPacket)outPacket); break; case QQCommand.Friend_Data_OP: ProcessFriendDataOpReply((FriendDataOpReplyPacket)inPacket, (FriendDataOpPacket)outPacket); break; case QQCommand.Friend_Level_OP: ProcessFriendLevelOpReply((FriendLevelOpReplyPacket)inPacket, (FriendLevelOpPacket)outPacket); break; case QQCommand.User_Property_OP: PocessUserPropertyOpReply((UserPropertyOpReplyPacket)inPacket, (UserPropertyOpPacket)outPacket); break; case QQCommand.Download_Group_Friend: ProcessDownloadGroupFriendReply((DownloadGroupFriendReplyPacket)inPacket, (DownloadGroupFriendPacket)outPacket); break; case QQCommand.Group_Data_OP: ProcessGroupNameOpReply((GroupDataOpReplyPacket)inPacket, (GroupDataOpPacket)outPacket); break; case QQCommand.Search_User: ProcessSearchUserReply((SearchUserReplyPacket)inPacket, (SearchUserPacket)outPacket); break; case QQCommand.Weather_OP: ProcessWeatherOpReply((WeatherOpReplyPacket)inPacket, (WeatherOpPacket)outPacket); break; } }
public bool Accept(LumaQQ.NET.Packets.InPacket inPacket) { return(inPacket.GetFamily() == ProtocolFamily.Basic); }