예제 #1
0
        static void wsServer_NewMessage(object sender, NewMessageEventArgs args)
        {
            Console.WriteLine("New Message: " + args.Message);

            foreach (var client in _clients)
            {
                _wsServer.SendMessage(client, args.Message);
            }
        }
예제 #2
0
 /// <summary>
 /// Raises the <see cref="E:NewMessage" /> event.
 /// </summary>
 /// <param name="eventArgs">The <see cref="NewMessageEventArgs"/> instance containing the event data.</param>
 private void OnNewMessage(NewMessageEventArgs eventArgs)
 {
     if (NewMessage != null)
         NewMessage(this, eventArgs);
 }
예제 #3
0
 static void wsServer_NewMessage(object sender, NewMessageEventArgs args)
 {
     Console.WriteLine("New Message: " + args.Message);
     _wsServer.SendMessage(args.Client, args.Message);
 }
예제 #4
0
        private void _webSocket_NewMessage(object sender, NewMessageEventArgs args)
        {
            var message = JsonConvert.DeserializeObject<Message>(args.Message);
            var type = Type.GetType("CC.Logic.Commands" + "." + message.Type + "Command");
            if (type == null)
                return;

            var command = Activator.CreateInstance(type) as BaseCommand;
            if (command == null)
                return;

            if (typeof (InitCommand) == command.GetType())
                _clients.Add(args.Client);

            var returnContent = command.Handle(message.Arguments);

            if(!string.IsNullOrEmpty(returnContent))
                _webSocket.SendMessage(args.Client, returnContent);
        }