void OnRemoteOperationRequest(IMessage msg, SessionEventArgs e) { RemoteOperationState state = RemoteOperationState.Failed; try { if (e.Session.SessionId == null) { state = RemoteOperationState.InvalidOpt; } else { var query = msg.Obj as TransmitData <RemoteInfoQuery>; if (query == null) { state = RemoteOperationState.Failed; } else { var sessionId = e.Session.SessionId as UserSessionIdMetaData; if (!_shopBll.HasAuditShop(sessionId.Id)) { state = RemoteOperationState.NotAuditShop; goto Response; } var clientSession = Global.GetSession(new UserSessionIdMetaData { Id = sessionId.Id, IsClient = true }); if (clientSession == null || !clientSession.IsOpened) { state = RemoteOperationState.ClientOffline; goto Response; } var toClientSession = Global.GetSession(new UserSessionIdMetaData { Id = query.ToUser.Id, IsClient = true }); if (toClientSession == null || !toClientSession.IsOpened) { state = RemoteOperationState.ToClientOffline; goto Response; } if (_userBll.GetGold(sessionId.Id) < 100) { state = RemoteOperationState.Goldless; goto Response; } query.Data.UserId = sessionId.Id; query.Data.UserAccount = sessionId.Account; var future = toClientSession.Send(query.Data, MessageType.RemoteOperationRequest); if (future == null) { state = RemoteOperationState.ToClientOffline; } else { state = RemoteOperationState.Successed; } } } } catch (Exception ex) { state = RemoteOperationState.Failed; ErrorLog(msg.Header.Type, ex); } Response: if (state != RemoteOperationState.Successed) { e.Session.Send(new DataResponse <RemoteOperationState, RemoteClientInfo> { State = state }, MessageType.RemoteOperationResponse); } }