コード例 #1
0
    public override void BoltStartDone()
    {
        base.BoltStartDone();

        Disconnect();

        _lbClient = new PhotonLoadBalancingClient();
        _lbClient.OnEventAction       += OnEventAction;
        _lbClient.OnOpResponseAction  += OnOpResponseAction;
        _lbClient.OnStateChangeAction += OnStateChangeAction;

        _lbClient.AutoJoinLobby = true;

        _lbClient.AppId = _config.AppId;
        if (_config.UseOnPremise)
        {
            _lbClient.Connect(_config.OnPremiseServerIpAddress, _config.AppId, "1.0", "", null);
        }
        else
        {
            _lbClient.ConnectToRegionMaster(_config.RegionMaster);
        }

        PunchAPI.RegisterPhotonClient(_lbClient, BoltNetwork.UdpSocket.LanEndPoint);
    }
コード例 #2
0
    void Update()
    {
        if (_lbClient == null)
        {
            return;
        }

        // clear send/recv pools when getting connected
        if (_lbClient.State == ClientState.Joined && _lbClient.State != _state)
        {
            _packetSend.Clear();
            _packetRecv.Clear();
        }

        if (_lbClient.State == ClientState.JoinedLobby)
        {
            if (_roomUpdateTimer.Expired)
            {
                // update
                BoltNetwork.UpdateSessionList(FetchSessionListFromPhoton());

                //
                _roomUpdateTimer = new Timer(ROOM_UPDATE_RATE);
            }
        }

        // poll in/out
        PollIn();
        PollOut();

        // store state
        _state = _lbClient.State;

        PunchAPI.Service();
    }
コード例 #3
0
        private void HandlerEvent(EventData evt)
        {
            int    otherIDJoin = 0;
            string info        = null;

            if (evt.Parameters.ContainsKey(ParameterCode.ActorNr))
            {
                otherIDJoin = (int)evt.Parameters[ParameterCode.ActorNr];
            }

            if (evt.Parameters.ContainsKey(ParameterCode.Data))
            {
                info = evt.Parameters[ParameterCode.Data].ToString();
            }

            PunchAPI.HandlerPhotonEvent(evt.Code, otherIDJoin, info);
        }