コード例 #1
0
        /// <summary>
        /// Method that extracts data from the messagebuffer in the socket state
        /// </summary>
        /// <param name="ss">Socket state whose message buffer data is extracted from</param>
        public void ReceiveWorld(SocketState ss)
        {
            string message;

            lock (ss.sb)
            {
                message = (ss.sb.ToString());

                // Clear the string builder in the socket state
                ss.sb.Remove(0, ss.sb.Length);
            }

            ReceivedMessage m = JsonConvert.DeserializeObject <ReceivedMessage>(message);
            UsersRecieved   n = JsonConvert.DeserializeObject <UsersRecieved>(message);

            if (n != null)
            {
                if ((n.N != null))
                {
                    UpdateSpreadsheet(parseUserList(message));
                }
                else if (m != null)
                {
                    if (m.type == "list")
                    {
                        SendSetupToView(m.spreadsheets);
                    }
                }
            }

            try
            {
                Networking.GetData(ss);
            }
            catch (Exception)
            {
                ResetConnection();
            }
        }
コード例 #2
0
        /// <summary>
        ///             ||| TO DO!!!  |||
        /// Method used to extract the world size and playerID from the server
        /// </summary>
        /// <param name="ss"></param>
        private void ExtractFirstData(SocketState ss)
        {
            string message;

            lock (ss.sb)
            {
                message = (ss.sb.ToString());

                // Clear the string builder in the socket state
                ss.sb.Remove(0, ss.sb.Length);
            }

            //Possible edited version to original
            //ReceiveAdminMessage l = JsonConvert.DeserializeObject<ReceiveAdminMessage>(message);
            //SendSetupToView(l.users, l.spreadsheets);
            //send l to form.cs->look at sendsetuptoview

            ReceivedMessage l = JsonConvert.DeserializeObject <ReceivedMessage>(message);

            if (l.type == "list")
            {
                SendSetupToView(l.spreadsheets);
            }
        }