コード例 #1
0
 public void Connect(string url, bool ssl)
 {
     _client            = new DdpConnection();
     _client.Login     += OnLogin;
     _client.Connected += OnConnected;
     _client.Connect(url, ssl);
     _client.Error  += OnError;
     _client.Closed += OnClosed;
 }
コード例 #2
0
        static void Main(string [] args)
        {
            _client            = new DdpConnection("localhost:3000");
            _client.Retry      = true;
            _client.Login     += Login;
            _client.Connected += OnConnected;
            _client.Connect();

            Console.ReadKey();
            _client.Close();
        }
コード例 #3
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("Connecting ...");
            ddpConnection.Connect();
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            Debug.Log("Closing connection ...");
            ddpConnection.Close();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            friendSub         = ddpConnection.Subscribe("friends");
            friendSub.OnReady = (Subscription obj) => {
                Debug.Log("Ready subscription: " + obj.id);
            };
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            ddpConnection.Unsubscribe(friendSub);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            ddpConnection.Call("friends.removeAll");
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            MethodCall methodCall = ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco"));
            methodCall.OnUpdated = (MethodCall obj) => {
                Debug.Log("Updated, methodId=" + obj.id);
            };
            methodCall.OnResult = (MethodCall obj) => {
                Debug.Log("Result = " + obj.result);
            };
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            MethodCall methodCall = ddpConnection.Call("friends.add", JSONObject.Create(7), JSONObject.Create(5));
            methodCall.OnUpdated = (MethodCall obj) => {
                Debug.Log("Updated, methodId=" + obj.id);
            };
            methodCall.OnResult = (MethodCall obj) => {
                Debug.Log("Result = " + obj.result);
            };
        }
    }
コード例 #4
0
ファイル: Program.cs プロジェクト: spadillar/DDPClient-NET
        private static void Main(string[] args)
        {
            _client            = new DdpConnection();
            _client.Login     += OnLogin;
            _client.Closed    += OnClose;
            _client.Error     += OnError;
            _client.Connected += OnConnected;
            _client.Connect("localhost:3000");

            Console.ReadKey();
            _client.Close();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: JohnnyCrazy/DDPClient-NET
        private static void Main(string[] args)
        {
            _client = new DdpConnection();
            _client.Login += OnLogin;
            _client.Closed += OnClose;
            _client.Error += OnError;
            _client.Connected += OnConnected;
            _client.Connect("localhost:3000");

            Console.ReadKey();
            _client.Close();
        }
コード例 #6
0
    public void Connect()
    {
        Debug.Log("connecting to " + serverUrl);
        ddpConnection = new DdpConnection(serverUrl);
        ddpConnection.OnDebugMessage += (string message) =>
        {
            Debug.Log(message);
        };
        ddpConnection.OnConnected += (DdpConnection connection) => {
            Debug.Log("connected!");
            ddpConnection.Subscribe("cube");
            ddpConnection.Subscribe("sphere");
            ddpConnection.Subscribe("monkey");
        };

        ddpConnection.OnError += DdpConnection_OnError;
        SetupDB();
        ddpConnection.Connect();
    }
コード例 #7
0
        public void ShouldHandleConnectSuccess()
        {
            _mock.Setup(websocket => websocket.Connect(It.IsAny <string>())).Callback(() => _mock.Raise(webSocket => webSocket.Opened += null, null, EventArgs.Empty));

            bool wasRaised = false;
            EventHandler <EventArgs> handler = null;

            handler = (sender, args) =>
            {
                wasRaised         = true;
                _connection.Open -= handler;
            };
            _connection.Open += handler;

            _connection.Connect("");

            Assert.IsTrue(wasRaised);
            _mock.Verify(webSocket => webSocket.Connect(It.IsAny <string>()));
            _mock.Verify(webSocket => webSocket.SendJson(It.IsAny <ConnectModel>()));
        }
コード例 #8
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("Connecting ...");
            ddpConnection.Connect();
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            ddpConnection.Close();
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            StartCoroutine(account.CreateUserAndLogin(username, password));
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            StartCoroutine(account.Login(username, password));
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            StartCoroutine(account.ResumeSession(token));
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            Debug.Log("Token " + account.token + " expires at " + account.tokenExpiration);
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            StartCoroutine(account.Logout());
        }
    }
コード例 #9
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("Connecting ...");
            ddpConnection.Connect();
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            ddpConnection.Close();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            friendSub         = ddpConnection.Subscribe("friends");
            friendSub.OnReady = (Subscription obj) => {
                Debug.Log("Ready subscription: " + obj.id);
            };
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            ddpConnection.Unsubscribe(friendSub);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            ddpConnection.Call("friends.removeAll");
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco"));
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            foreach (var entry in friendCollection.documents)
            {
                Debug.Log(entry.Key + " " + entry.Value);
            }
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            JSONObject parents = new JSONObject();
            parents.AddField("mother", "wonder woman");
            parents.AddField("father", "batman");
            JSONObject attr = new JSONObject();
            attr.AddField("age", 24);
            attr.AddField("height", 180);
            attr.AddField("parents", parents);
            ddpConnection.Call("friends.addAttributes", JSONObject.StringObject("Coco"), attr);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            JSONObject attr = new JSONObject();
            attr.AddField("age", 1);
            attr.AddField("height", 1);
            attr.AddField("parents.mother", 1);
            ddpConnection.Call("friends.removeAttributes", JSONObject.StringObject("Coco"), attr);
        }
    }