public NotificationMessage CreateNotificationMessage(ISerializer serializer, IHostAddress clientHostAddress, string objectId, string methodName) { var payload = serializer.Serialize(_serializedParameters); return(new NotificationMessage(clientHostAddress, objectId, methodName, payload, _selector, _objectIds)); }
public static Message ReadInternal(IHostAddress clientHostAddress, IFrame frame) { var objectId = frame.TakeString(); var eventName = frame.TakeString(); return(new SubscribeEventMessage(clientHostAddress, objectId, eventName)); }
public static Message ReadInternal(IHostAddress clientHostAddress, IFrame frame) { var errorType = (ErrorType)frame.TakeByte(); var message = frame.TakeString(); return(new ErrorMessage(clientHostAddress, errorType, message)); }
public EventHandlersRepository(IOutputChannel outputChannel, IHostAddress clientHostAddress, EloquentClient eloquentClient) { _outputChannel = outputChannel; _clientHostAddress = clientHostAddress; _eloquentClient = eloquentClient; }
public static Message ReadInternal(IHostAddress clientHostAddress, IFrame frame) { var payload = frame.TakeBuffer(); var selector = frame.TakeBoolArray(); var objectIds = frame.TakeStringArray(); return(new ResponseMessage(clientHostAddress, payload, selector, objectIds)); }
public EventMessage(IHostAddress clientHostAddress, string objectId, string eventName, byte[] serializedParameters, bool[] selector, string[] objectIds) : base(clientHostAddress) { ObjectId = objectId; EventName = eventName; SerializedParameters = serializedParameters; Selector = selector; ObjectIds = objectIds; }
internal RequestMessage(IHostAddress clientHostAddress, string objectId, string methodName, byte[] serializedParameters, bool[] selector, string[] objectIds) : base(clientHostAddress) { ObjectId = objectId; MethodName = methodName; SerializedParameters = serializedParameters; Selector = selector; ObjectIds = objectIds; }
public static Message ReadInternal(IHostAddress clientHostAddress, IFrame frame) { var objectId = frame.TakeString(); var methodName = frame.TakeString(); var payload = frame.TakeBuffer(); var selector = frame.TakeBoolArray(); var objectIds = frame.TakeStringArray(); return(new NotificationMessage(clientHostAddress, objectId, methodName, payload, selector, objectIds)); }
public Subscription(string objectId, string eventName, IHostAddress clientHostAddress, IOutputChannel outputChannel, IEvent @event) { _outputChannel = outputChannel; _event = @event; ObjectId = objectId; ClientHostAddress = clientHostAddress; _event.Add(this); }
/// <summary> /// Creates an EloquentObjects client with ability to specify custom settings and dependencies. /// </summary> /// <param name="serverAddress">Address of the server that hosts object. Can be prefixed with 'tcp://' for TCP binding or 'pipe://' for Named Pipes binding</param> /// <param name="clientAddress">Client-side address that is used to send server-to-client events. Can be prefixed with 'tcp://' for TCP binding or 'pipe://' for Named Pipes binding</param> /// <param name="settings">Custom settings</param> /// <param name="serializerFactory">Factory that can create serializer to be used for serializing/deserializing data sent between server and client</param> /// <exception cref="ArgumentException">Client Uri scheme should match server Uri scheme</exception> public EloquentClient(string serverAddress, string clientAddress, EloquentSettings settings, [CanBeNull] ISerializerFactory serializerFactory = null) { _serializerFactory = serializerFactory ?? new DefaultSerializerFactory(); var serverUri = new Uri(serverAddress); var clientUri = new Uri(clientAddress); var serverScheme = serverUri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped); var clientScheme = clientUri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped); if (serverScheme != clientScheme) { throw new ArgumentException("Client Uri scheme should match server Uri scheme"); } var binding = new BindingFactory().Create(serverScheme, settings); var serverHostAddress = HostAddress.CreateFromUri(serverUri); _clientHostAddress = HostAddress.CreateFromUri(clientUri); _contractDescriptionFactory = new CachedContractDescriptionFactory(new ContractDescriptionFactory()); _proxyGenerator = new ProxyGenerator(); try { _inputChannel = binding.CreateInputChannel(_clientHostAddress); } catch (Exception e) { throw new IOException("Failed creating input channel", e); } try { _outputChannel = binding.CreateOutputChannel(serverHostAddress); } catch (Exception e) { throw new IOException("Connection failed. Server not found.", e); } _inputChannel.Start(); //Send HelloMessage to create a session var helloMessage = new HelloMessage(_clientHostAddress); _outputChannel.SendWithAck(helloMessage); _eventHandlersRepository = new EventHandlersRepository(_outputChannel, _clientHostAddress, this); _sessionAgent = new SessionAgent(binding, _inputChannel, _outputChannel, _clientHostAddress, _eventHandlersRepository); }
public Connection(string objectId, object outerProxy, IEventHandlersRepository eventHandlersRepository, IContractDescription contractDescription, ISerializer serializer, IEloquentClient eloquentClient, IOutputChannel outputChannel, IHostAddress clientHostAddress) { _objectId = objectId; _outerProxy = outerProxy; _eventHandlersRepository = eventHandlersRepository; _contractDescription = contractDescription; _serializer = serializer; _eloquentClient = eloquentClient; _outputChannel = outputChannel; _clientHostAddress = clientHostAddress; }
public Session(IBinding binding, IHostAddress clientHostAddress, IObjectsRepository objectsRepository, IOutputChannel outputChannel) { _maxHeartBeatLost = binding.MaxHeartBeatLost; _objectsRepository = objectsRepository; _outputChannel = outputChannel; ClientHostAddress = clientHostAddress; _objectsRepository.ObjectRemoved += ObjectsRepositoryOnObjectRemoved; //When HeartBeatMs is 0 then no heart beats are listened. if (binding.HeartBeatMs != 0) { _heartbeatTimer = new Timer(Heartbeat, null, 0, binding.HeartBeatMs); } _logger = Logger.Factory.Create(GetType()); _logger.Info(() => $"Created (clientHostAddress = {ClientHostAddress})"); }
public SessionAgent(IBinding binding, IInputChannel inputChannel, IOutputChannel outputChannel, IHostAddress clientHostAddress, IEventHandlersRepository eventHandlersRepository) { _inputChannel = inputChannel; _outputChannel = outputChannel; _clientHostAddress = clientHostAddress; _eventHandlersRepository = eventHandlersRepository; _inputChannel.FrameReceived += InputChannelOnFrameReceived; //Start sending heartbeats. When HeartBeatMs is 0 then no heart beats are sent. lock (_heartbeatTimerLock) { if (binding.HeartBeatMs != 0) { _heartbeatTimer = new Timer(Heartbeat, null, 0, binding.HeartBeatMs); } } _logger = Logger.Factory.Create(GetType()); _logger.Info(() => $"Created (clientHostAddress = {_clientHostAddress})"); }
private void HandleRequest(IHostAddress clientHostAddress, IInputContext context, string methodName, object[] parameters) { if (_disposed) { throw new ObjectDisposedException(nameof(ObjectAdapter)); } var operationDescription = _contractDescription.GetOperationDescription(methodName, parameters); object result; try { result = _synchronizationContext != null ? CallInSyncContext(operationDescription, parameters) : operationDescription.Method.Invoke(Object, parameters.ToArray()); } catch (Exception e) { //Send exception back to client WriteException(context, e.InnerException ?? e, clientHostAddress); return; } if (_objectsRepository.TryGetObjectId(result, out var objectId)) { var responseMessage = new ResponseMessage(clientHostAddress, new byte[] { }, new [] { true }, new[] { objectId }); context.Write(responseMessage.ToFrame()); } else { var payload = _serializer.Serialize(result); var responseMessage = new ResponseMessage(clientHostAddress, payload, new [] { false }, new string[] { }); context.Write(responseMessage.ToFrame()); } }
internal ConnectMessage(IHostAddress clientHostAddress, string objectId) : base( clientHostAddress) { ObjectId = objectId; }
public static Message ReadInternal(IHostAddress hostAddress, IFrame frame) { var objectId = frame.TakeString(); return(new ConnectMessage(hostAddress, objectId)); }
public SubscribeEventMessage(IHostAddress clientHostAddress, string objectId, string eventName) : base(clientHostAddress) { ObjectId = objectId; EventName = eventName; }
internal ExceptionMessage(IHostAddress clientHostAddress, FaultException exception) : base( clientHostAddress) { Exception = exception; }
internal ResponseMessage(IHostAddress clientHostAddress, byte[] serializedParameters, bool[] selector, string[] objectIds) : base(clientHostAddress) { SerializedParameters = serializedParameters; Selector = selector; ObjectIds = objectIds; }
internal TerminateMessage(IHostAddress clientHostAddress) : base(clientHostAddress) { }
public static Message ReadInternal(IHostAddress clientHostAddress, IFrame frame) { var exception = FaultException.Read(frame); return(new ExceptionMessage(clientHostAddress, exception)); }
internal HeartbeatMessage(IHostAddress clientHostAddress) : base(clientHostAddress) { }
protected Message(IHostAddress clientHostAddress) { ClientHostAddress = clientHostAddress; }
public EventMessage CreateEventMessage(ISerializer serializer, IHostAddress clientHostAddress, string objectId, string eventName) { var payload = serializer.Serialize(_serializedParameters); return(new EventMessage(clientHostAddress, objectId, eventName, payload, _selector, _objectIds)); }
public static Message ReadInternal(IHostAddress hostAddress, IFrame frame) { return(new AckMessage(hostAddress)); }
internal AckMessage(IHostAddress clientHostAddress) : base(clientHostAddress) { }
public static Message ReadInternal(IHostAddress hostAddress) { return(new HeartbeatMessage(hostAddress)); }
public IInputChannel CreateInputChannel(IHostAddress address) { return(new InputChannel(IPAddress.Parse(address.IpAddress), address.Port, _sendTimeout)); }
protected AcknowledgedMessage(IHostAddress clientHostAddress) : base(clientHostAddress) { }
public IOutputChannel CreateOutputChannel(IHostAddress address) { return(new OutputChannel(IPAddress.Parse(address.IpAddress), address.Port, _sendTimeout, _receiveTimeout)); }