public WebSocketEventNotifier(IWebSocketManager manager, IExternalEventSubscription externalEventSubscription)
 {
     this.serialiser = new WebSocketDataSerialisation();
     this.externalEventSubscription = externalEventSubscription;
     this.webSocketManager = manager;
     this.webSocketManager.SocketDisconnected += this.WebSocketManagerOnSocketDisconnected;
     this.webSocketManager.MessageReceived += this.WebSocketManagerOnMessageReceived;
 }
Exemplo n.º 2
0
        public void SerialiseDummyEventToExpectedFormat()
        {
            var dummyEvent = this.GetDummyEvent();
            string expectedMessage =
            @"content-type:application/vnd.meungblut.websockets.dummyevent+json

            {""id"":""6a8d7bcb-4d16-4b22-af52-60be3860ab86"",""someData"":""some data""}";
            var serialiser = new WebSocketDataSerialisation();
            var serialisedMessage = serialiser.GetString(dummyEvent);
            Assert.AreEqual(expectedMessage, serialisedMessage);
        }
Exemplo n.º 3
0
        public void DeserialiseDummyEvent()
        {
            string messageToDeserialise =
            @"content-type:application/vnd.meungblut.websockets.dummyevent+json

            {""id"":""6a8d7bcb-4d16-4b22-af52-60be3860ab86"",""someData"":""some data""}";
            var serialiser = new WebSocketDataSerialisation();

            WebSocketDataSerialisation.AddTypeToDeserialise("content-type:application/vnd.meungblut.websockets.dummyevent+json", typeof(DummyEvent));

            var deserialisedObject = (DummyEvent)serialiser.GetObject(messageToDeserialise);

            Assert.AreEqual("6a8d7bcb-4d16-4b22-af52-60be3860ab86", deserialisedObject.Id);
            Assert.AreEqual("some data", deserialisedObject.SomeData);
        }
Exemplo n.º 4
0
 public void SendMessage(string webSocketId, IDomainEvent domainEvent)
 {
     var serialiser = new WebSocketDataSerialisation();
     this.managers[webSocketId].BroadcastToAllClients(serialiser.GetString(domainEvent));
 }
Exemplo n.º 5
0
 public static void SendMessage(IDomainEvent domainEvent)
 {
     var serialiser = new WebSocketDataSerialisation();
     superWebsocketManager.BroadcastToAllClients(serialiser.GetString(domainEvent));
 }