/// <summary> /// データ受信のコールバック /// </summary> /// <param name="ar"></param> void ReceiveDataCallback(IAsyncResult ar) { StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; //Debug.Log(handler == connectedClient); int readSize = handler.EndReceive(ar); if (readSize < 1) { return; } OnRecieveData?.Invoke(this, state.buffer); }
/// <summary> /// データ受信のコールバック /// </summary> /// <param name="ar"></param> void ReceiveCallback(IAsyncResult ar) { StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; //Debug.Log(handler == connectedClient); int readSize = handler.EndReceive(ar); if (readSize < 1) { return; } OnRecieveData?.Invoke(this, state.buffer); //ChangeReceiveDataIntoCommand(bb); //ServerMain.Instance.SetData(bb); //handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); //Array.Copy(state.buffer, bb, readSize); //bb = ChangeReceiveDataIntoCommand(bb); //handler.BeginSend(bb, 0, bb.Length, 0, new AsyncCallback(WriteCallback), state); }
protected void OnReceivedDataHandler(string d) { OnRecieveData?.Invoke(d); }