private void JoinEventHandler(UdpSession session) { if (BoltNetwork.IsClient) { BoltMatchmaking.JoinSession(session); } }
public override void SessionListUpdated(Map <Guid, UdpSession> sessionList) { ClearSessions(); foreach (var session in sessionList) { UdpSession photonSession = session.Value as UdpSession; Button joinGameBtn = Instantiate(joinGameButtonPrefab); joinGameBtn.transform.SetParent(serverListPanel.transform); joinGameBtn.transform.localPosition = new Vector3(0, 0, 0); joinGameBtn.gameObject.SetActive(true); joinGameBtn.gameObject.GetComponentInChildren <Text>().text = photonSession.HostName; joinGameBtn.onClick.AddListener(() => JoinGame(photonSession)); joinButtons.Add(joinGameBtn); } float startPos = (float)Math.Floor(joinButtons.Count / 2f) * buttonSpacing; for (int i = 0; i < joinButtons.Count; ++i) { joinButtons[i].transform.localPosition = new Vector3(0, startPos - (i * buttonSpacing), 0); } }
protected override SOCK_SERV_ERROR AddToRelevantManager(Session sess) { SOCK_SERV_ERROR ret = SOCK_SERV_ERROR.SUCCESS; Debug.Assert(null != sess); Debug.Assert(sess is UdpSession); User user = UserManager.Instance.AllocateUser(); if (null != user) { UdpSession user_sess = (UdpSession)sess; user_sess.SetObject(user); user.SetUserSession(user_sess); user.SendUdpAuthPacket(); } else { ret = SOCK_SERV_ERROR.E_USER_SESSION_IS_EMPTY; } return(ret); }
public void SetRemotePort(int port) { Debug.Assert(m_UserSession is UdpSession); UdpSession udp_sess = m_UserSession as UdpSession; udp_sess.SetRemotePort(port); }
void JoinMatch(UdpSession match, LobbyManager lobbyManager) { BoltNetwork.Connect(match); lobbyManager.backDelegate = lobbyManager.Stop; lobbyManager.DisplayIsConnecting(); }
public override void SessionListUpdated(Map <Guid, UdpSession> matches) { if (matches.Count == 0) { noServerFound.SetActive(true); return; } noServerFound.SetActive(false); foreach (Transform t in serverListRect) { Destroy(t.gameObject); } int i = 0; foreach (var pair in matches) { UdpSession udpSession = pair.Value; GameObject o = Instantiate(serverEntryPrefab) as GameObject; o.GetComponent <LobbyServerEntry>().Populate(udpSession, lobbyManager, (i % 2 == 0) ? OddServerColor : EvenServerColor); o.transform.SetParent(serverListRect, false); ++i; } }
private void OnPeerConnected(NetPeer peer) { _Logger.LogInformation($"OnPeerConnected {peer.Id}"); UdpSession session = new UdpSession(peer, _ClusterClient, _LoggerFactory); _Sessions.Add(peer.Id, session); }
public void Event_SessionCreatedOrUpdated(UdpSession session) { Log.Info(LogChannel, $"[PhotonNetworkInterface] SessionCreatedOrUpdated: session:{session.Id} name:{session.HostName}"); _connectedSessionInfo = new PhotonNetworkInterfaceSession(session); ConcludeOperationCallback(ref _operationCallbackSessionCreated, true, null); }
private void JoinSession(UdpSession udpSession) { if (udpSession.Source == UdpSessionSource.Photon) { BoltNetwork.Connect(udpSession); } }
void JoinMatch(UdpSession match, LobbyManager lobbyManager) { BoltNetwork.Connect(match, SteamManager.instance.GetConnectToken()); lobbyManager.backDelegate = lobbyManager.Stop; lobbyManager.DisplayIsConnecting(); }
private void JoinEventHandler(UdpSession session) { if (BoltNetwork.IsClient) { BoltNetwork.Connect(session); } }
void ShowSessionList(Dictionary <Guid, UdpSession> sessionList) { foreach (var session in sessionList) { UdpSession udpSession = session.Value as UdpSession; // Skip if is not a Photon session if (udpSession.Source != UdpSessionSource.Photon) { BoltLog.Info("UdpSession with different Source: {0}", udpSession.Source); continue; } PhotonSession photonSession = udpSession as PhotonSession; if (photonSession == null) { continue; } string sessionDescription = String.Format("{0} ({1})", photonSession.HostName, photonSession.Id); IProtocolToken token = photonSession.GetProtocolToken(); // Normal Token RoomProtocolToken roomToken = token as RoomProtocolToken; if (roomToken != null) { sessionDescription += String.Format(" :: {0}", roomToken.ArbitraryData); } object prop_type = -1; object prop_map = -1; if (photonSession.Properties.ContainsKey("t")) { prop_type = photonSession.Properties["t"]; } if (photonSession.Properties.ContainsKey("m")) { prop_map = photonSession.Properties["m"]; } sessionDescription += String.Format(" :: {0} / {1}", prop_type, prop_map); if (GUILayout.Button(sessionDescription, GUILayout.ExpandWidth(true))) { ServerConnectToken connectToken = new ServerConnectToken { data = "ConnectTokenData" }; BoltNetwork.Connect(photonSession, connectToken); } } }
public void StartSendToAsync(string ip_addr, int port) { Debug.Assert(m_UserSession is UdpSession); UdpSession udp_session = m_UserSession as UdpSession; udp_session.CreateUdpSocket(this, ip_addr, port); udp_session.StartSendToAsync(); }
public override void SessionCreated(UdpSession session) { SessionCreatedUIHandler(session); // Build Server Entity var entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo); entity.TakeControl(); }
public override void SessionConnectFailed(UdpSession session, IProtocolToken token) { var photonSession = session as PhotonSession; string sessionDescription = String.Format("{0} / {1} ({2})", photonSession.Source, photonSession.HostName, photonSession.Id); BoltLog.Warn("Failed to Connect to: {0}", sessionDescription); }
public void Populate(UdpSession match, Color backgroundColor, Action clickAction) { serverInfoText.text = match.HostName; slotInfo.text = string.Format("{0}/{1}", match.ConnectionsCurrent, match.ConnectionsMax); joinButton.onClick.RemoveAllListeners(); joinButton.onClick.AddListener(clickAction.Invoke); gameObject.GetComponent <Image>().color = backgroundColor; }
// BOLT public override void SessionCreated(UdpSession session) { if (!_sessionCreated) { CreatePlayerEntry(_myPlayerSettings.Nickname); UpdateCurrentPlayerCount(1); _sessionCreated = true; } }
public override void SessionCreated(UdpSession session) { SwitchMenu(hostGameWindow, sessionWindow); var hostInfo = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo); hostInfo.TakeControl(); CheckMinPlayerRequirements(); }
public void StartConnection(UdpSession session, ClientConnectionToken token, Action onConnectSuccess, Action <ClientConnectFailReason> onConnectFail) { StopAllCoroutines(); networkingMode = NetworkingMode.Client; state = State.Connecting; token.Version = Version; StartCoroutine(ConnectClientRoutine(session, token, onConnectSuccess, onConnectFail)); }
public override void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete) { _operationCallbackSessionConnected = onComplete; UdpSession udpSession = ((PhotonNetworkInterfaceSession)session).UdpSession; BoltMatchmaking.JoinSession(udpSession); _connectedSessionInfo = session; }
public override void SessionConnectFailed(UdpSession session, IProtocolToken token) { base.SessionConnectFailed(session, token); if (state == State.Connecting) { connectionAttemptInfo.IsFailed = true; state = BoltNetwork.IsRunning ? State.Active : State.Inactive; } }
void JoinMatch(UdpSession match, NetworkManager lobbyManager) { BoltNetwork.Connect(match); lobbyManager.backDelegate = lobbyManager.Stop; lobbyManager.DisplayIsConnecting(); lobbyManager.matchName = match.HostName; joinButton.enabled = false; //lobbyManager.infoPanel.Display(); }
public void Populate(UdpSession match, NetworkManager lobbyManager, Color c) { serverInfoText.text = match.HostName; slotInfo.text = match.ConnectionsCurrent.ToString() + "/" + match.ConnectionsMax.ToString();; joinButton.onClick.RemoveAllListeners(); joinButton.onClick.AddListener(() => { JoinMatch(match, lobbyManager); }); GetComponent <Image>().color = c; }
public override void SessionListUpdated(Map <Guid, UdpSession> sessionList) { foreach (var session in sessionList) { UdpSession photonSession = session.Value as UdpSession; if (photonSession.Source == UdpSessionSource.Photon) { BoltMatchmaking.JoinSession(photonSession); } } }
private void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectinfo) { UdpSession session = null; if (_Sessions.TryGetValue(peer.Id, out session)) { session.Close(); } _Sessions.Remove(peer.Id); }
public override void SessionListUpdated(Map <Guid, UdpSession> sessionList) { foreach (var session in sessionList) { UdpSession photonSession = session.Value as UdpSession; if (photonSession.Source == UdpSessionSource.Photon) { BoltNetwork.Connect(photonSession); } } }
private void SessionCreatedUIHandler(UdpSession session) { uiInfoPanel.ToggleVisibility(false); object region; BoltMatchmaking.CurrentMetadata.TryGetValue("region", out region); uiTopPanel.SetHeaderInfo("Host", "self", ((string)region).ToUpper()); ChangeBodyTo(uiRoom); }
IEnumerator GetList() { foreach (var session in BoltNetwork.SessionList) { UdpSession photonSession = session.Value as UdpSession; Debug.Log(photonSession.Id); } yield return(new WaitForSeconds(2f)); StartCoroutine(GetList()); }
//For join Room public override void SessionListUpdated(Map <Guid, UdpSession> sessionList) { //This sessionlist will is Photon Stuff so all the sessionlist goes to photon server // basically loops through all the sessionlist foreach (var session in sessionList) { UdpSession photonSession = session.Value as UdpSession; if (photonSession.Source == UdpSessionSource.Photon) { BoltNetwork.Connect(photonSession); } } }
private async void OnNetworkReceive(NetPeer peer, NetPacketReader reader, DeliveryMethod clientDeliveryMethod) { NList msg = ProtoUtils.Deserialize <NList>(reader.GetBytesWithLength()); UdpSession session = null; if (_Sessions.TryGetValue(peer.Id, out session)) { await session.IncomingMessage(msg); } _NetManager.TriggerUpdate(); reader.Recycle(); }
private void ReceiveCompleted(object sender, SocketAsyncEventArgs e) { if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success) { int lenght = BitConverter.ToInt32(e.Buffer, 0); short cmdId = BitConverter.ToInt16(e.Buffer, intByteLength); byte[] data = new byte[lenght]; System.Buffer.BlockCopy(e.Buffer, checkLenght, data, 0, lenght); ReceiveCommond rCmd = new ReceiveCommond() { CommondId = cmdId, Data = data }; if (rCmd != null) { UdpSession session = new UdpSession(e.RemoteEndPoint, this); ThreadPool.QueueUserWorkItem(_ => { OnReceived(session, rCmd); }); } } this.BeginReceive(e); }