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) { RRMessageQueue msgQueue = RRMessageQueue.getInstance(); msgQueue.AddMessage(args.event_id, args); } } } }
// Use this for initialization void Start() { //Canvas Initialization gObj = new GameObject(); gObj.name = "SelectionCanvas"; Canvas canvas = gObj.AddComponent <Canvas> (); canvas.renderMode = RenderMode.ScreenSpaceOverlay; CanvasScaler cs = gObj.AddComponent <CanvasScaler> (); cs.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; GraphicRaycaster gRay = gObj.AddComponent <GraphicRaycaster> (); //Button stored by position spot1 = 0; spot2 = 1; //Initialize Buttons initButtons(); mainObject = GameObject.Find("MainObject"); cManager = RRConnectionManager.getInstance(); // NetworkRequestTable.init(); // NetworkResponseTable.init(); RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRSTARTGAME, ResponseRRStartGame); RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRGETMAP, ResponseRRGetMap); RequestRRGetMap reqmap = new RequestRRGetMap(); reqmap.Send(); cManager.Send(reqmap); }
void Awake() { sInstance = this; callbackList = new Dictionary <int, Callback> (); msgQueue = new Queue <ExtendedEventArgs> (); }
void OnDestroy() { RRMessageQueue.getInstance().RemoveCallback(Constants.SMSG_RRSTARTGAME); RRMessageQueue.getInstance().RemoveCallback(Constants.SMSG_RRGETMAP); }
void Awake() { sInstance = this; callbackList = new Dictionary<int, Callback> (); msgQueue = new Queue<ExtendedEventArgs> (); }
void OnDestroy() { RRMessageQueue.getInstance().RemoveCallback(Constants.SMSG_RRENDGAME); }
// Update is called once per frame void Update() { time += Time.deltaTime; if (flag) { StartCoroutine(Delay()); } if (!speedUpFlag) { StartCoroutine(SpeedUpDelay()); } if (!speedDownFlag) { StartCoroutine(SpeedDownDelay()); } if (speedReturnFlag) { StartCoroutine(SpeedReturnDelay()); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { if (cManager) { RequestKeyboard rk = new RequestKeyboard(); rk.send(1, -1); cManager.Send(rk); } } if (Input.GetKeyDown(KeyCode.RightArrow)) { if (cManager) { RequestKeyboard rk = new RequestKeyboard(); rk.send(1, 1); cManager.Send(rk); } } if (Input.GetKeyDown(KeyCode.Space)) { if (cManager) { RequestKeyboard rk = new RequestKeyboard(); rk.send(2, 1); cManager.Send(rk); } } if (Input.GetKeyUp(KeyCode.LeftArrow) && cManager) { RequestKeyboard rk = new RequestKeyboard(); rk.send(1, 0); cManager.Send(rk); } if (Input.GetKeyUp(KeyCode.RightArrow) && cManager) { RequestKeyboard rk = new RequestKeyboard(); rk.send(1, 0); cManager.Send(rk); } if (Input.GetKeyUp(KeyCode.Space) && cManager) { RequestKeyboard rk = new RequestKeyboard(); rk.send(2, 0); cManager.Send(rk); } if (!called) { RRMessageQueue.getInstance().AddCallback(Constants.SMSG_RRENDGAME, ResponseRREndGame); called = true; } }