/// <summary cref="Notify(string, object, int)"> /// </summary> public void Notify(string route, object msg, int timeout = -1) { IPitayaSerializer serializer = SerializerFactory.CreateJsonSerializer(); if (msg is IMessage) { serializer = SerializerFactory.CreateProtobufSerializer(_binding.ClientSerializer(_client)); } NotifyInternal(route, msg, serializer, timeout); }
/// <summary cref="Request<TResponse>(string, object, Action<TResponse>, Action<PitayaError>, int)"> /// </summary> public void Request <TResponse>(string route, object msg, Action <TResponse> action, Action <PitayaError> errorAction, int timeout = -1) { IPitayaSerializer serializer = SerializerFactory.CreateJsonSerializer(); if (msg is IMessage) { serializer = SerializerFactory.CreateProtobufSerializer(_binding.ClientSerializer(_client)); } RequestInternal(route, msg, timeout, serializer, action, errorAction); }
/// <summary cref="OnRoute<T>(string, Action<T>)"> /// </summary> public void OnRoute <T>(string route, Action <T> action) { IPitayaSerializer serializer = SerializerFactory.CreateJsonSerializer(); if (typeof(IMessage).IsAssignableFrom(typeof(T))) { serializer = SerializerFactory.CreateProtobufSerializer(_binding.ClientSerializer(_client)); } OnRouteInternal(route, action, serializer); }
private void OnRouteInternal <T>(string route, Action <T> action, IPitayaSerializer serializer) { Action <byte[]> responseAction = res => { action(serializer.Decode <T>(res)); }; _eventManager.AddOnRouteEvent(route, responseAction); }
private void NotifyInternal(string route, object msg, IPitayaSerializer serializer, int timeout = -1) { _binding.Notify(_client, route, serializer.Encode(msg), timeout); }
void RequestInternal <TResponse, TRequest>(string route, TRequest msg, int timeout, IPitayaSerializer serializer, Action <TResponse> action, Action <PitayaError> errorAction) { _reqUid++; Action <byte[]> responseAction = res => { action(serializer.Decode <TResponse>(res)); }; _eventManager.AddCallBack(_reqUid, responseAction, errorAction); _binding.Request(_client, route, serializer.Encode(msg), _reqUid, timeout); }