Пример #1
0
        public void JsonRpcDispatchNotify()
        {
            // setup
            var typeRegistry = new TypeRegistry();
            var method       = typeRegistry.RPCFunc((int a, int b) => a + b);
            var dispatcher   = new RPCDispatcher();

            dispatcher.AddNotifyMethod("Add", method);

            // notify
            var notify = "{\"jsonrpc\":\"2.0\",\"method\":\"Add\",\"params\":[1,2]}";

            dispatcher.DispatchNotify(notify.ParseAsJson());
        }
Пример #2
0
        public void MsgPackRpcDispatchNotify()
        {
            // setup
            var typeRegistry = new TypeRegistry();
            var method       = typeRegistry.RPCFunc((int a, int b) => a + b);
            var dispatcher   = new RPCDispatcher();

            dispatcher.AddNotifyMethod("Add", method);

            // notify
            var notify = new RPCNotify <Osaru.MessagePack.MessagePackParser>
            {
                Method      = "Add",
                ParamsBytes = typeRegistry.SerializeToMessagePack(new[] { 1, 2 })
            };

            dispatcher.DispatchNotify(notify);
        }