public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
        {
            BoltLog.Info("ConnectRequest", Color.red);

            if (token != null)
            {
                BoltLog.Info("Token Received", Color.red);
            }

            BoltNetwork.Accept(endpoint);
        }
Esempio n. 2
0
    IEnumerator SetHostInfoRoutine(String servername, Boolean dedicated, Bolt.IProtocolToken protocolToken)
    {
        var t = new Timer(ROOM_CREATE_TIMEOUT);

        while (_lbClient.State != ClientState.JoinedLobby && t.Waiting)
        {
            yield return(null);
        }

        if (_lbClient.State != ClientState.JoinedLobby)
        {
            BoltLog.Error("Can't call BoltNetwork.SetHostInfo when not in lobby");
            yield break;
        }

        //
        var maxPlayers = dedicated ? BoltNetwork.maxConnections : BoltNetwork.maxConnections + 1;

        // check for null token and create one
        var token = protocolToken as PhotonHostInfoToken;

        if (token == null)
        {
            token = new PhotonHostInfoToken();
        }

        if (token.CustomRoomProperties == null)
        {
            token.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();
        }

        token.CustomRoomProperties ["UdpSessionId"] = Guid.NewGuid().ToString();

        if (_config.UsePunchThrough)
        {
            token.CustomRoomProperties ["SocketPeerId"] = BoltNetwork.UdpSocket.SocketPeerId.ToString();
        }

        //
        _lbClient.OpCreateRoom(servername, new RoomOptions()
        {
            CustomRoomProperties         = token.CustomRoomProperties,
            CustomRoomPropertiesForLobby = new string[] {
                "UdpSessionId",
                "SocketPeerId"
            },
            MaxPlayers = (byte)maxPlayers,
        }, null);
    }
Esempio n. 3
0
    public Boolean JoinSession(UdpSession session, Bolt.IProtocolToken token)
    {
        if (session.Source == UdpSessionSource.Photon)
        {
            if (_connectState != ConnectState.Idle)
            {
                BoltLog.Error("Already attempting connection to a photon room");
                return(true);
            }

            if (_lbClient.State != ClientState.JoinedLobby)
            {
                BoltLog.Error("Can't call BoltNetwork.Connect when not in lobby");
                return(true);
            }

            _currentConnectRoutine = StartCoroutine(JoinSessionRoutine(session, token));
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 4
0
    IEnumerator JoinSessionRoutine(UdpSession session, Bolt.IProtocolToken token)
    {
        Timer timer;

        ChangeState(ConnectState.JoinRoomPending);

        LoadBalancerClient.OpJoinRoom(session.HostName);

        // request new session list from zeus
        Zeus.RequestSessionList();

        //
        timer = new Timer(ROOM_JOIN_TIMEOUT);

        while (_lbClient.State != ClientState.Joined && timer.Waiting)
        {
            yield return(null);
        }

        if (_lbClient.State != ClientState.Joined)
        {
            _currentConnectRoutine = null;
            BoltLog.Error("Failed to join room");
            ChangeState(ConnectState.Idle);
            yield break;
        }

        // if we have a zeus session available for this
        if (_config.UsePunchThrough)
        {
            var s = (PhotonSession)session;
            if (s._socketPeerId != Guid.Empty)
            {
                UdpSession zeusSession;

                if (BoltNetwork.SessionList.TryFind(s._socketPeerId, out zeusSession) && zeusSession.Source == UdpSessionSource.Zeus)
                {
                    ChangeState(ConnectState.DirectPending);

#if TEST_FAIL
                    BoltNetwork.Connect(new UdpEndPoint(new UdpIPv4Address(0, 45, 0, 0), unchecked ((ushort)-1)));
#else
                    BoltNetwork.Connect(zeusSession);
#endif

                    while (_connectState == ConnectState.DirectPending)
                    {
                        yield return(null);
                    }

                    if (_connectState == ConnectState.DirectSuccess)
                    {
                        ChangeState(ConnectState.Idle);
                        yield break;
                    }
                }
            }
        }

        _currentConnectRoutine = null;

        ChangeState(ConnectState.RelayPending);
        BoltNetwork.Connect(new UdpEndPoint(new UdpIPv4Address((uint)HostPlayerId), 0), token);

        while (_connectState == ConnectState.RelayPending)
        {
            yield return(null);
        }

        if (_connectState == ConnectState.RelayFailed)
        {
            BoltLog.Error("Connecting to photon room '{0}' failed", session.HostName);
        }

        ChangeState(ConnectState.Idle);
    }
Esempio n. 5
0
 public void SetHostInfo(String servername, Boolean dedicated, Bolt.IProtocolToken protocolToken)
 {
     StartCoroutine(SetHostInfoRoutine(servername, dedicated, protocolToken));
 }
Esempio n. 6
0
        public override void SceneLoadLocalDone(string scene, Bolt.IProtocolToken token)
        {
            var entity = BoltNetwork.Instantiate(BoltPrefabs.CharacterPainter);

            entity.TakeControl();
        }
Esempio n. 7
0
 public override void SceneLoadLocalBegin(string scene, Bolt.IProtocolToken token)
 {
     //Debug.LogWarning("Se ejecuta SceneLoadLocalBegin");
 }
 public override void SessionConnectFailed(UdpSession session, Bolt.IProtocolToken token)
 {
     OnNetworkingError(new NetworkError("Lobby Connect Failed", "No clue :)", ":("));
 }