示例#1
0
        public void Request <T>(string route, IMessage msg, int timeout, Action <T> action, Action <PitayaError> errorAction)
        {
            _reqUid++;
            _typeRequestSubscriber.Subscribe(_reqUid, typeof(T));

            Action <object> responseAction = res => { action((T)res); };

            _eventManager.AddCallBack(_reqUid, responseAction, errorAction);

            var serializer = PitayaBinding.ClientSerializer(_client);

            PitayaBinding.Request(_client, route, ProtobufSerializer.Encode(msg, serializer), _reqUid, timeout);
        }
示例#2
0
        public void OnUserDefinedPush(string route, byte[] serializedBody)
        {
            object decoded;

            if (_typePushSubscriber.HasType(route))
            {
                var type = _typePushSubscriber.GetType(route);
                decoded = ProtobufSerializer.Decode(serializedBody, type, PitayaBinding.ClientSerializer(_client));
            }
            else
            {
                decoded = JsonSerializer.Decode(serializedBody);
            }

            _eventManager.InvokeOnEvent(route, decoded);
        }
示例#3
0
        //---------------Pitaya Listener------------------------//

        public void OnRequestResponse(uint rid, byte[] data)
        {
            object decoded;

            if (_typeRequestSubscriber.HasType(rid))
            {
                var type = _typeRequestSubscriber.GetType(rid);
                decoded = ProtobufSerializer.Decode(data, type, PitayaBinding.ClientSerializer(_client));
            }
            else
            {
                decoded = JsonSerializer.Decode(data);
            }

            _eventManager.InvokeCallBack(rid, decoded);
        }
示例#4
0
        public void Notify(string route, int timeout, IMessage msg)
        {
            var serializer = PitayaBinding.ClientSerializer(_client);

            PitayaBinding.Notify(_client, route, ProtobufSerializer.Encode(msg, serializer), timeout);
        }