public void Sendn(ref DataPacketString message) { CReadyNetWork netWork = CReadyNetWork.GetInstance(); NetworkStream stream = netWork.GetStream(); try { byte[] sizeBuffer = new byte[ConstVaue.IntSize]; DataPacketInt size = new DataPacketInt(message.GetStrLen()); Serialize(size, ref sizeBuffer); stream.Write(sizeBuffer, 0, ConstVaue.IntSize); byte[] messageBuffer = new byte[ConstVaue.BufSize]; Serialize(message, ref messageBuffer); stream.Write(messageBuffer, 0, message.GetStrLen()); } catch (Exception e) { Debug.Log(e.Message); message.Message = "Exception"; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Return)) { DataPacketString message = new DataPacketString(mField.text); Sender.Sendn(ref message); } }
private CListener() { mStream = CReadyNetWork.GetInstance().GetStream(); mMessage = new DataPacketString(); mThreadListen = new Thread(new ThreadStart(Listen)); Debug.Log("listen 시작"); mThreadListen.Start(); }