/// <summary> /// 게임을 종료되었을시 실행 /// </summary> public void GameOverClear() { ShipIndex = -1; P2PGroupID = HostID.HostID_None; _totalPlayerList.Clear(); _connetedList.Clear(); }
public void SetClient(ClientInfo client) { if (client != null) { _playerInfo = client; _uid = _playerInfo.UniqID; _remoteID = _playerInfo.RemoteID; _localIndex = _playerInfo.locaIndex; if (IdentityUI != null) { GlobalUtil.AddString(GlobalUtil.Scolor[client.locaIndex], client.Name, GlobalUtil.ColorEnd); IdentityUI.SetUIData(client.UniqID, client.LifeCount, GlobalUtil.GetText); if (_playerInfo.IsJoin) { IdentityUI.ShowBaseUI(); } else { IdentityUI.HideBaseUI(); } } } else { if (IdentityUI != null) { IdentityUI.HideBaseUI(); } } }
// RMI stub public bool ShowChat(HostID remote, RmiContext rmiContext, string a, int b, float c) { LogList.Add("[m_client] ShowChat : a=" + a + ", b=" + b + ", c=" + c); m_scrollPosition.y = m_scrollHeight; return(true); }
public bool SystemChat(HostID remote, RmiContext rmiContext, string txt) { LogList.Add("[m_client] SystemChat : txt=" + txt); m_scrollPosition.y = m_scrollHeight; return(true); }
// Use this for initialization void Start() { m_netClient.P2PMemberJoinHandler = (HostID memberHostID, HostID groupHostID, int memberCount, ByteArray customField) => { m_myP2PGroupID = groupHostID; ServerRoom.instance.MachingComplete(); m_state = State.MachingComplete; }; m_S2CStub.ReplyLogon = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int clientID) => { m_myhostID = (HostID)clientID; CardDatabase.Instance().InitData(); SetP2PRmiStub(); return(true); }; m_S2CStub.ReplyClientCount = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int clientCount) => { ServerRoom.instance.ClientCount = clientCount; return(true); }; m_S2CStub.SendCardData = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, CardData cardData) => { CardDatabase.Instance().AddCardData(cardData); return(true); }; }
public ShipReservate(ClientInfo client) { RemoteID = client.RemoteID; NickName = client.Name; CharIndex = client.CharacterIndex; UID = client.UniqID; Connected = true; }
/// <summary> /// 현재 P2P 접속한 클라이언트 /// </summary> /// <param name="findID"></param> /// <returns></returns> public ClientInfo GetConnectedClientInfo(HostID findID) { ClientInfo findResult; _connetedList.TryGetValue(findID, out findResult); return(findResult); }
/// <summary> /// p2p 방 나갈시 유저 제거용 함수 /// </summary> /// <param name="delUser"></param> public void RemoveConnectedPlayer(HostID removeID) { if (_connetedList.Count < 1) { return; } ClientInfo remover; }
public bool AckExistID(HostID remote, RmiContext rmiContext, string playID, bool exist) { //UIManager.i.Notice("AckExistID"); UIManager.i.Notice("사용할 닉네임을 적어주세요."); UIManager.i.GetPagePopupUI <UILoginPage>().ReceiveIDCheckResult(playID, exist); return(true); }
public ClientInfo(long id, string name, HostID remote) { GameBoard = new GameScoreBoard(); UniqID = id; Name = name; RemoteID = remote; P2PGroupID = HostID.HostID_None; }
/// <summary> /// P2P 새로운 멤버 입장시 불림 ( 내가 어느 배에 들어갈때도 불림 ) /// </summary> public void P2P_NoticeMemberJoin(HostID memberHostID, HostID groupHostID, int memberCount, ByteArray customField) { //Debug.LogFormat("P2P {0} , Join Host {1}, localIndex {2}", groupHostID, memberHostID); /*if (!Equals(TakeSceneManager.i.CurrentState, SCENENAME.InShipGameScene)) * { * Debug.Log("게임 씬이 아님"); * return; * }*/ }
public void Sleep() { _remoteID = HostID.HostID_None; SetClient(null); if (IndicatorUI) { IndicatorUI.gameObject.SetActive(false); } }
public void OnP2PMemberJoin(HostID memberHostID, HostID groupHostID, int memberCount, ByteArray customField) { SimpleApp.print("[Client] P2P member " + memberHostID + " joined group " + groupHostID + "."); this.GroupID = groupHostID; if (memberHostID != m_client.LocalHostID) { m_simpleProxy.P2PChat(memberHostID, RmiContext.ReliableSend, "Hello~~", 1, 1); } }
public System.Object GetHostTag(HostID hostID) { System.Object hostTag = null; lock (thisLock) { m_hostTagDictionary.TryGetValue(hostID, out hostTag); } return(hostTag); }
public Player GetPlayer(HostID remote) { for (int i = 0; i < PlayerList.Count; i++) { if (PlayerList[i].RemoteID == remote) { return(PlayerList[i]); } } return(null); }
public void Clear() { State = RoomState.OVER; MatchType = MatchType.NONE; MaxPlayer = 2; RoomID = 0; P2PGroup = HostID.HostID_None; if (PlayerList != null) { PlayerList.Clear(); } Timestamp = 0; BallResList = new List <int>(); ReadyPlayerCount = 0; }
public bool SetHostTag(HostID hostID, System.Object hostTag) { lock (thisLock) { if (m_hostTagDictionary.ContainsKey(hostID)) { m_hostTagDictionary[hostID] = hostTag; } else { m_hostTagDictionary.Add(hostID, hostTag); } return(true); } }
public void Start() { m_netClient.AttachProxy(m_C2SProxy); m_netClient.AttachStub(m_S2CStub); //Proxy와 Stub값을 넣어줍니다 m_eState = eState.LoggingOn; //상태값을 바꾸어줍니다 m_netClient.JoinServerCompleteHandler = JoinServerCompleteHandler; // 서버 로그인 완료 후 이벤트 m_netClient.LeaveServerHandler = LeaveServerHandler; //서버가 끊긴것에 대하 정보 m_S2CStub.ReplyLogon = ReplyLogon; // RequestLogon 후 이벤트 m_netClient.AttachProxy(m_C2Croxy); //p2p(클라이언트 간의) Proxy와 m_netClient.AttachStub(m_C2CStub); //stub값을 넣어줍니다 m_C2CStub.Player_1Point = Player_1Point; //클라이언트 간에 교환할 Player1,2의 위치값 정보 m_C2CStub.Player_2Point = Player_2Point; m_netClient.P2PMemberJoinHandler = (HostID memberHostID, HostID groupHostID, int memberCount, ByteArray customField) => { m_p2pGroupID = groupHostID; //P2P그룹에서 HostID 를 받아온다 }; }
public bool P2PChat(HostID remote, RmiContext rmiContext, string a, int b, float c) { string relayed = ""; if (rmiContext.relayed == true) { relayed = "true"; } else { relayed = "false"; } LogList.Add("[m_client] P2PChat relayed:" + relayed + ", a=" + a + ", b=" + b + ", c=" + c); m_scrollPosition.y = m_scrollHeight; return(true); }
public void MoveRemoteClientToLoadedVille(HostID remote, Ville_S ville, String nickName) { RemoteClient_S remoteClientValue; Ville_S villeValue; if (!ville.m_players.TryGetValue(remote, out remoteClientValue) && !m_remoteClients.TryGetValue(remote, out villeValue)) { ville.m_players.TryAdd(remote, new RemoteClient_S(nickName, ville.nextLocation)); ville.UpdateNextLoc(ville.nextLocation); m_remoteClients.TryAdd(remote, ville); } // now, the player can do P2P communication with other player in the smae ville. m_netServer.JoinP2PGroup(remote, ville.m_p2pGroupID); // check nickname ville.m_players.TryGetValue(remote, out remoteClientValue); Console.WriteLine("Client NickName : {0}", remoteClientValue.nickName); //notify current world state to new user foreach (KeyValuePair <int, WorldObject_S> iWO in ville.m_worldOjbects) { m_S2CProxy.NotifyAddTree(remote, RmiContext.ReliableSend, (int)ville.m_p2pGroupID, iWO.Value.m_id, iWO.Value.m_position); } Console.WriteLine("masterID: {0}", ville.masterID); Console.WriteLine("<Update Client List>"); // notify current players list to new user foreach (KeyValuePair <HostID, RemoteClient_S> iPlayer in ville.m_players) { Console.WriteLine("{0}", iPlayer.Value.nickName); m_S2CProxy.NotifyPlayerJoin(remote, RmiContext.ReliableSend, (int)ville.m_p2pGroupID, iPlayer.Value.nickName, iPlayer.Value.waitingIdx); } // except remote, notfy a new Player enters foreach (KeyValuePair <HostID, RemoteClient_S> iPlayer in ville.m_players) { if (iPlayer.Key == remote) { continue; } m_S2CProxy.NotifyPlayerJoin(iPlayer.Key, RmiContext.ReliableSend, (int)ville.m_p2pGroupID, remoteClientValue.nickName, remoteClientValue.waitingIdx); } }
public void MoveRemoteClientToLoadedVille(HostID remote, Ville_S ville) { RemoteClient_S remoteClientValue; Ville_S villeValue; if (!ville.m_players.TryGetValue(remote, out remoteClientValue) && !m_remoteClients.TryGetValue(remote, out villeValue)) { ville.m_players.TryAdd(remote, new RemoteClient_S()); m_remoteClients.TryAdd(remote, ville); } // now, the player can do P2P communication with other player in the same ville. m_netServer.JoinP2PGroup(remote, ville.m_p2pGroupID); // notify current world state to new user foreach (KeyValuePair <int, WorldObject_S> iWO in ville.m_worldObjects) { m_S2CProxy.NotifyAddTree(remote, RmiContext.ReliableSend, (int)ville.m_p2pGroupID, iWO.Value.m_id, iWO.Value.m_position); } }
public ClientEventSink(NetClient client, Simple.Proxy proxy) { m_client = client; m_simpleProxy = proxy; IsConnectWaiting = true; IsConnected = false; GroupID = HostID.HostID_None; m_client.JoinServerCompleteHandler = OnJoinServerComplete; m_client.LeaveServerHandler = OnLeaveServer; m_client.P2PMemberJoinHandler = OnP2PMemberJoin; m_client.P2PMemberLeaveHandler = OnP2PMemberLeave; m_client.ErrorHandler = OnError; m_client.WarningHandler = OnWarning; m_client.ExceptionHandler = OnException; m_client.InformationHandler = OnInformation; m_client.NoRmiProcessedHandler = OnNoRmiProcessed; m_client.ChangeServerUdpStateHandler = OnChangeServerUdp; m_client.ReceivedUserMessageHandler = OnReceiveUserMessage; }
/// <summary> /// P2P 접속시 유저 추가하는 함수 /// </summary> /// <param name="addUser"></param> public void AddConnectedPlayer(HostID remote, byte localIndex) { if (_totalPlayerList.Count < 1) { return; } ClientInfo member; if (_totalPlayerList.TryGetValue(localIndex, out member)) { member.RemoteID = remote; if (_connetedList.ContainsKey(remote) == false) { _connetedList.Add(remote, member); } } else { Debug.Log("존재하지 않는 플레이어 추가 에러 " + remote); } }
private bool ProcessMessage_Rmi(HostID remote, ByteArray arr) { Message msg = new Message(arr); int orgReadOffset = msg.ReadOffset; RmiID __rmiID; msg.Read(out __rmiID); // ProudNetLayer에서도 사용자정의Rmi에서도 해당 RmiID를 찾을 수 없다. if (!m_stubRmiIDList.Contains(__rmiID)) { if (noRmiProcessedHandler != null) { noRmiProcessedHandler(__rmiID); } return(false); } foreach (RmiStub stub in m_stubList) { msg.ReadOffset = orgReadOffset; ReceivedMessage recvMsg = new ReceivedMessage(); recvMsg.remoteHostID = remote; recvMsg.unsafeMessage = msg; if (stub.ProcessReceivedMessage(recvMsg, GetHostTag(remote))) { return(true); } } return(false); }
public void OnP2PMemberJoin(HostID memberHostID, HostID groupHostID, int memberCount, ByteArray customField) { m_GroupHostID = groupHostID; m_IsGroupHostID = true; }
public void OnException(HostID remoteID, System.Exception e) { SimpleApp.print("exception : " + e.ToString()); }
public void OnP2PMemberLeave(HostID memberHostID, HostID groupHostID, int memberCount) { SimpleApp.print("[Client] P2P member " + memberHostID + " left group " + groupHostID + "."); }
public void OnReceiveUserMessage(HostID sender, RmiContext rmiContext, ByteArray payload) { SimpleApp.print("ReceiveUserMessage HostID : " + sender); }
public void OnP2PMemberLeave(HostID memberHostID, HostID groupHostID, int memberCount) { }
public ShipData(Ship ship) { ShipID = ship.P2PGroupID; LocalIndexList = new Dictionary <long, byte>(); }
public FrameMoveResult FrameMove() { FrameMoveResult frameMoveResult = new FrameMoveResult(); for (int i = 0; i < m_eventQueue.Count; i++) { CallbackEvent evt; lock (thisLock) { // 먼저 들어온 다른 클라이언트의 이벤트를 더 늦게 처리하지 않기 위해 제일 앞의 연속된 이벤트만 처리한다. if (m_eventQueue[i].clientInstanceID != m_clientInstanceID) { Misc.WriteLog("instanceID : " + m_clientInstanceID + ", instanceID doesn't match. evt : " + m_eventQueue[0], System.Reflection.MethodBase.GetCurrentMethod().Name); break; } evt = m_eventQueue[i]; m_eventQueue.RemoveAt(i); i--; } Misc.WriteLog("instanceID : " + m_clientInstanceID + ", CallbackEvent : " + evt, System.Reflection.MethodBase.GetCurrentMethod().Name); switch (evt.type) { case CallbackType.JoinServerComplete: if (joinServerCompleteHandler != null) { joinServerCompleteHandler(evt.errorInfo, evt.replyFromServer); frameMoveResult.processedEventCount++; } break; case CallbackType.LeaveServer: if (leaveServerHandler != null) { leaveServerHandler(evt.errorInfo); frameMoveResult.processedEventCount++; } break; case CallbackType.SynchronizeServerTime: if (synchronizeServerTime != null) { synchronizeServerTime(); frameMoveResult.processedEventCount++; } break; case CallbackType.NoRmiProcessed: if (noRmiProcessedHandler != null) { noRmiProcessedHandler(evt.rmiID); frameMoveResult.processedEventCount++; } break; case CallbackType.ReceiveUserMessage: if (receiveUserMessageHandler != null) { receiveUserMessageHandler(evt.sender, evt.rmiContext, evt.byteArr); frameMoveResult.processedMessageCount++; } break; case CallbackType.Rmi: if (ProcessMessage_Rmi(evt.sender, evt.byteArr)) { frameMoveResult.processedMessageCount++; } break; case CallbackType.HostIDIssued: LocalHostID = evt.sender; break; default: break; } } Misc.WriteLog("instanceID : " + m_clientInstanceID + ", FrameMoveResult : [" + frameMoveResult.processedMessageCount + ", " + frameMoveResult.processedEventCount + "]", System.Reflection.MethodBase.GetCurrentMethod().Name); return(frameMoveResult); }
public bool SendUserMessage(HostID remote, RmiContext rmiContext, ByteArray payload) { HostID[] __list = new HostID[1]; __list[0] = remote; return(m_jsClient.SendUserMessage(m_clientInstanceID, __list, rmiContext, payload)); }
public void OnReceiveUserMessage(HostID sender, RmiContext rmiContext, ByteArray payload) { if (payload.Count <= (int)Command.Constant.MAX_PACKET_SIZE) { Loom.DispatchToMainThread(() => Deserialize.DeserializePacket(payload)); } }