コード例 #1
0
 private void JoinEventHandler(UdpSession session)
 {
     if (BoltNetwork.IsClient)
     {
         BoltMatchmaking.JoinSession(session);
     }
 }
コード例 #2
0
    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);
        }
    }
コード例 #3
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);
        }
コード例 #4
0
ファイル: User.cs プロジェクト: qcyzj/QGS-Framework-cs
        public void SetRemotePort(int port)
        {
            Debug.Assert(m_UserSession is UdpSession);
            UdpSession udp_sess = m_UserSession as UdpSession;

            udp_sess.SetRemotePort(port);
        }
コード例 #5
0
        void JoinMatch(UdpSession match, LobbyManager lobbyManager)
        {
            BoltNetwork.Connect(match);

            lobbyManager.backDelegate = lobbyManager.Stop;
            lobbyManager.DisplayIsConnecting();
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
ファイル: UdpSocketService.cs プロジェクト: neshlabs/nesh
        private void OnPeerConnected(NetPeer peer)
        {
            _Logger.LogInformation($"OnPeerConnected {peer.Id}");
            UdpSession session = new UdpSession(peer, _ClusterClient, _LoggerFactory);

            _Sessions.Add(peer.Id, session);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 private void JoinSession(UdpSession udpSession)
 {
     if (udpSession.Source == UdpSessionSource.Photon)
     {
         BoltNetwork.Connect(udpSession);
     }
 }
コード例 #10
0
        void JoinMatch(UdpSession match, LobbyManager lobbyManager)
        {
            BoltNetwork.Connect(match, SteamManager.instance.GetConnectToken());

            lobbyManager.backDelegate = lobbyManager.Stop;
            lobbyManager.DisplayIsConnecting();
        }
コード例 #11
0
 private void JoinEventHandler(UdpSession session)
 {
     if (BoltNetwork.IsClient)
     {
         BoltNetwork.Connect(session);
     }
 }
コード例 #12
0
ファイル: PhotonInit.cs プロジェクト: herpdederp/WorldEntity
        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);
                }
            }
        }
コード例 #13
0
ファイル: User.cs プロジェクト: qcyzj/QGS-Framework-cs
        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();
        }
コード例 #14
0
        public override void SessionCreated(UdpSession session)
        {
            SessionCreatedUIHandler(session);

            // Build Server Entity
            var entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo);

            entity.TakeControl();
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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;
        }
コード例 #17
0
        // BOLT

        public override void SessionCreated(UdpSession session)
        {
            if (!_sessionCreated)
            {
                CreatePlayerEntry(_myPlayerSettings.Nickname);
                UpdateCurrentPlayerCount(1);

                _sessionCreated = true;
            }
        }
コード例 #18
0
        public override void SessionCreated(UdpSession session)
        {
            SwitchMenu(hostGameWindow, sessionWindow);

            var hostInfo = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo);

            hostInfo.TakeControl();

            CheckMinPlayerRequirements();
        }
コード例 #19
0
        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));
        }
コード例 #20
0
        public override void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete)
        {
            _operationCallbackSessionConnected = onComplete;

            UdpSession udpSession = ((PhotonNetworkInterfaceSession)session).UdpSession;

            BoltMatchmaking.JoinSession(udpSession);

            _connectedSessionInfo = session;
        }
コード例 #21
0
        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;
            }
        }
コード例 #22
0
        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();
        }
コード例 #23
0
        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;
        }
コード例 #24
0
ファイル: Menu.cs プロジェクト: manhiem/Scribble
 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);
         }
     }
 }
コード例 #25
0
ファイル: UdpSocketService.cs プロジェクト: neshlabs/nesh
        private void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectinfo)
        {
            UdpSession session = null;

            if (_Sessions.TryGetValue(peer.Id, out session))
            {
                session.Close();
            }

            _Sessions.Remove(peer.Id);
        }
コード例 #26
0
ファイル: BenMenu.cs プロジェクト: DGMeyer96/Cyber-Arena-3079
 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);
         }
     }
 }
コード例 #27
0
ファイル: LobbyManager.UI.cs プロジェクト: prpo99/Bolt-Sample
        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);
        }
コード例 #28
0
    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());
    }
コード例 #29
0
 //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);
         }
     }
 }
コード例 #30
0
ファイル: UdpSocketService.cs プロジェクト: neshlabs/nesh
        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();
        }
コード例 #31
0
ファイル: UdpAsyncServer.cs プロジェクト: liwl/sunsocket
        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);
        }