Example #1
0
        void Awake()
        {
            DontDestroyOnLoad(gameObject);

            gameObject.AddComponent <RRMessageQueue>();
            gameObject.AddComponent <RRConnectionManager>();

            NetworkRequestTable.init();
            NetworkResponseTable.init();
        }
Example #2
0
        void Awake()
        {
            DontDestroyOnLoad(gameObject);

            gameObject.AddComponent("MessageQueue");
            gameObject.AddComponent("ConnectionManager");

            NetworkRequestTable.init();
            NetworkResponseTable.init();

            //SpeciesTable.initialize();
        }
        public void ReadSocket()
        {
            if (!socketReady)
            {
                return;
            }

            if (theStream.DataAvailable)
            {
                byte[] buffer = new byte[2];
                theStream.Read(buffer, 0, 2);
                short bufferSize = BitConverter.ToInt16(buffer, 0);

                buffer = new byte[bufferSize];
                theStream.Read(buffer, 0, bufferSize);
                MemoryStream dataStream = new MemoryStream(buffer);

                short response_id = DataReader.ReadShort(dataStream);
                Debug.Log("response_id: " + response_id);
                //Debug.Log(response_id.GetType().ToString());
                NetworkResponse response = NetworkResponseTable.get(response_id);

                if (response != null)
                {
                    response.dataStream = dataStream;

                    response.parse();
                    ExtendedEventArgs args = response.process();

                    if (args != null)
                    {
                        MessageQueue msgQueue = mainObject.GetComponent <MessageQueue>();
                        msgQueue.AddMessage(args.event_id, args);
                    }
                }
            }
        }