public LocationController( IServiceLocation serviceLocation, ILocationMapper locationMapper, IUrlHelper urlHelper ) { this.serviceLocation = serviceLocation; this.locationMapper = locationMapper; this.urlHelper = urlHelper; }
void PostMessage(HostCommunicator sender, IServiceLocation target, object message) { message = new ServiceMessage { SenderId = sender.Id, TargetId = ((ServiceLocation)target).Id, Body = message }; var json = JsonConvert.SerializeObject(message, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); var msg = Encoding.UTF8.GetBytes(json); udpClient.Send(msg, msg.Length, ((ServiceLocation)target).EndPoint); }
public TInterface Build(IServiceLocation <TInterface> location) { var resolver = _stubResolver; var handler = _stubHandler .Address(location.Address !) .Port(location.Port) .Meta(location.Meta !) .Tags(location.Tags !); var stub = resolver.Resolve <TInterface>(); var instance = (TInterface)Activator.CreateInstance(stub, $"{location.Address!.TrimEnd('/')!}{(location.Port == null ? ":" + location.Port : "")}", _factory.CreateClient()); if (!(instance is IStub)) { throw new ArgumentException(); } ((IStub)instance).UseHandler(handler); return(instance); }
protected virtual async Task OnMessageReceived(IServiceLocation sender, object message) { }
async Task HandleMessage(IServiceLocation sender, EntityMovedMessage message) { if (EntityMoved != null) EntityMoved(message); }
async Task HandleMessage(IServiceLocation sender, EntityCreatedMessage message) { if (EntityCreated != null) EntityCreated(message.EntityId); }
protected override async Task OnMessageReceived(IServiceLocation sender, object message) { await HandleMessage(sender, (dynamic)message); }
public void DoHandleMessageReceived(IServiceLocation sender, object message) { messageQueue.Add(new Message { Sender = sender, Content = message }); }
public void PostMessage(IServiceLocation target, object message) { host.PostMessage(this, target, message); }