//--------------------------------------------------------------------- async Task ICellPlayer.unsubPlayer(ICellPlayerObserver sub) { bool is_sub = Subscribers.IsSubscribed(sub); if (is_sub) { Subscribers.Unsubscribe(sub); } // 通知EtPlayer服务端:客户端断开了 if (Subscribers.Count == 0 && EtPlayer != null) { var co_player = EtPlayer.getComponent <CellPlayer <DefPlayer> >(); await co_player.c2sClientDeattach(); DeactivateOnIdle(); } }
//--------------------------------------------------------------------- Task ICellPlayer.subPlayer(ICellPlayerObserver sub, IPEndPoint remote_endpoint) { if (Subscribers.Count > 0) { Logger.Info("subPlayer() 重复登陆,踢出前一帐号 Subscribers.Count={0}", Subscribers.Count); AccountNotify account_notify; account_notify.id = AccountNotifyId.Logout; account_notify.data = EbTool.protobufSerialize <ProtocolResult>(ProtocolResult.LogoutNewLogin); MethodData notify_data = new MethodData(); notify_data.method_id = MethodType.s2cAccountNotify; notify_data.param1 = EbTool.protobufSerialize <AccountNotify>(account_notify); Subscribers.Notify((s) => s.s2cNotify(notify_data)); } Subscribers.Subscribe(sub); var co_player = EtPlayer.getComponent <CellPlayer <DefPlayer> >(); co_player.c2sClientAttach(remote_endpoint); return(TaskDone.Done); }