Ejemplo n.º 1
0
 public static void AddConnection(ObservablePhotonPeer peer)
 {
     connectionInfos.Add(new ConnectionInfoViewModel(peer)
     {
         FoldOut = true
     });
 }
Ejemplo n.º 2
0
            public ConnectionInfoViewModel(ObservablePhotonPeer peer)
            {
                this.MaxSize     = "0B";
                this.MaxSent     = "0B";
                this.MaxReceived = "0B";
                this.Peer        = new WeakReference(peer);
                this.GraphList   = new CircularBuffer <UniRx.Tuple <int, int> >(lastWidth);

                var interval = TimeSpan.FromMilliseconds(100);

                var send        = peer.ObserveSendOpCustom().Select(x => GetSize(x)).Buffer(interval, Scheduler.ThreadPool);
                var sendReceive = peer.ObserveOperationResponse().Select(x => GetSize(x.OperationResponse.Parameters)).Buffer(interval, Scheduler.ThreadPool);
                var receive     = peer.ObserveReceiveEventData().Select(x => GetSize(x.Parameters)).Buffer(interval, Scheduler.ThreadPool);

                subscription = Observable.Zip(send, sendReceive, receive, (x, y, z) => Tuple.Create(x.Sum(), y.Sum() + z.Sum()))
                               .Subscribe(x =>
                {
                    lock (GraphListLock)
                    {
                        TotalSent     += x.Item1;
                        TotalReceived += x.Item2;
                        GraphList.Enqueue(x);
                    }
                });
            }
Ejemplo n.º 3
0
        public static void Initialize(TestContext cx)
        {
            Peer = new ObservablePhotonPeer(ExitGames.Client.Photon.ConnectionProtocol.Tcp)
            {
                Timeout = TimeSpan.FromSeconds(5)
            };
            var task = Peer.ConnectAsync("127.0.0.1:4530", "ServerApp");

            task.Wait(); // wait for timeout seconds...
        }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        var peer = new ObservablePhotonPeer(ExitGames.Client.Photon.ConnectionProtocol.Tcp, "Test", 20);

        var proxy = peer.CreateTypedHub <SimpleHubProxy>();



        proxy.AttachInvokeFilter(x => new MogeMoge1(x));
        proxy.AttachInvokeFilter(x => new MogeMoge2(x));
        proxy.AttachReceiveFilter(x => new NugaNuga1(x));

        proxy.Publish.ToClient(100, 2000);

        proxy.Receive.ToClient().Subscribe(_ => { });
    }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var observablePeer = new ObservablePhotonPeer(ConnectionProtocol.Tcp);

            observablePeer.Timeout = TimeSpan.FromMinutes(15); // toooooo long


            observablePeer.DebugOut = DebugLevel.ALL;
            observablePeer.Connect("127.0.0.1:4530", "ServerApp");

            Observable.Interval(TimeSpan.FromMilliseconds(50)).Subscribe(_ => observablePeer.Service());

            StatusCode lastStatus = StatusCode.Disconnect;

            observablePeer.ObserveStatusChanged().Subscribe(x =>
            {
                lastStatus = x;
                Console.WriteLine(x);
            });

            Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(_ =>
            {
                if (lastStatus != StatusCode.Connect)
                {
                    observablePeer.Connect("127.0.0.1:4530", "ServerApp");
                }
            });


            // Create Typed Proxy
            var hub = observablePeer.CreateTypedHub <SimpleHubProxy>();

            hub.RegisterListener(new Listener());



            hub.Publish.Blank();
            hub.Publish.Single(100);
            hub.Publish.ToClient(10, 20);

            while (true)
            {
                Console.ReadLine();
            }
        }