Beispiel #1
0
        internal static void InfoMessage(ClientSession session, IWebSocketConnection socket)
        {
            string        datas         = session.SessionPlayer.ToString();
            ServerMessage messageResult = new ServerMessage(session.Id, "info", datas);

            socket.Send(messageResult.ToString());
        }
Beispiel #2
0
        internal static void LooseMessage(ClientSession session, IWebSocketConnection socket)
        {
            string        datas         = null;
            ServerMessage messageResult = new ServerMessage(session.Id, "loose", datas);

            socket.Send(messageResult.ToString());
        }
Beispiel #3
0
        internal static void ReceipeMessage(ClientSession session, IWebSocketConnection socket)
        {
            string        datas         = ItemCrafting.Instance.ToString();
            ServerMessage messageResult = new ServerMessage(session.Id, "receipes", datas);

            socket.Send(messageResult.ToString());
        }
Beispiel #4
0
        internal static void BoardMessage(ClientSession session, IWebSocketConnection socket, Grid grid)
        {
            string        datas         = grid.GetViewPlayerString(session.SessionPlayer);
            ServerMessage messageResult = new ServerMessage(session.Id, "board", datas);

            socket.Send(messageResult.ToString());
        }
Beispiel #5
0
        internal static void MapMessage(ClientSession session, IWebSocketConnection socket, Grid grid)
        {
            //Cheat version
            //string map = grid.GetViewMapString();
            //Regular version
            string        map           = grid.GetViewPlayerMapString(session.SessionPlayer);
            string        datas         = "{\"width\":" + grid.Width + ",\"height\":" + grid.Height + ",\"map\":" + map + "}";
            ServerMessage messageResult = new ServerMessage(session.Id, "map", datas);

            socket.Send(messageResult.ToString());
        }
Beispiel #6
0
        private static void OnOpen(IWebSocketConnection socket)
        {
            ClientSession client = new ClientSession(grid);

            clients.Add(socket, client);
            Console.WriteLine("Open client " + client.Id);
            ServerMessage result = new ServerMessage(client.Id, "connected", null);

            socket.Send(result.ToString());

            MessageSender.BoardMessage(client, socket, grid);
            MessageSender.InfoMessage(client, socket);
            MessageSender.ReceipeMessage(client, socket);
        }