Esempio n. 1
1
    // Use this for initialization
    void Start()
    {
        loadBalancingClient = new LoadBalancingClient(null, TurnbasedAppId, "1.0"); // the master server address is not used when connecting via nameserver

        AuthenticationValues customAuth = new AuthenticationValues();
        customAuth.AddAuthParameter("username", UserName);  // expected by the demo custom auth service
        customAuth.AddAuthParameter("token", UserToken);    // expected by the demo custom auth service
        loadBalancingClient.AuthValues = customAuth;

        loadBalancingClient.AutoJoinLobby = false;
        loadBalancingClient.ConnectToRegionMaster("us");
    }
Esempio n. 2
0
    //
    void Awake()
    {
        // set singleton instance
        if (PhotonAccess.instance == null) {
            PhotonAccess.instance = this;
        } else {
            Destroy (this);
        }

        // Connect to Photon Turnbased
        Debug.Log ("Photon: Photon Start!");
        if (string.IsNullOrEmpty(AppId)) {
            Debug.LogError ("Photon: AppID not set!");
            Debug.Break ();
        }
        Application.runInBackground = true;

        this.client = new LoadBalancingClient();
        this.client.AppId = this.AppId;

        if (!this.client.ConnectToRegionMaster ("jp")) {
            Debug.LogError ("Photon: Cannnot connect!");
            Debug.Break();
        }
    }
Esempio n. 3
0
    public void OnApplicationPause(bool willPause)
    {
        if (willPause)
        {
            lock (threadClientLock)
            {
                threadClient = this.GameInstance;
            }
            thread = new Thread(this.SendAcks);
            thread.IsBackground = true;
            thread.Start();
        }
        else
        {
            lock (threadClientLock)
            {
                threadClient = null;
            }
        }

        if (this.GameInstance == null || this.GameInstance.loadBalancingPeer == null)
        {
            return;
        }

        LoadBalancingPeer lbPeer = this.GameInstance.loadBalancingPeer;
        Debug.Log("OnApplicationPause " + (willPause ? "SLEEP":"WAKE") + " time: "+ DateTime.Now.ToLongTimeString() + " " +lbPeer.BytesIn +"in "+ lbPeer.BytesOut + "out");

        if (!willPause)
        {
            lbPeer.Service();
            int timeSinceLastReceive = Environment.TickCount - lbPeer.TimestampOfLastSocketReceive;
            Debug.Log("IsConnectedAndReady: " + this.GameInstance.IsConnectedAndReady + " timeSinceLastReceive: " + timeSinceLastReceive);
        }
    }
Esempio n. 4
0
 public CommandUI(ConcurrentQueue<Message> inbox, ConcurrentQueue<Message> outbox, LoadBalancingClient client)
     : base(inbox, outbox)
 {
     this.client = client;
 }