private void MonsterSet(InputMemoryStream inInputStream, short Count) { lock (lockObject) { for (int i = 0; i < Count; i++) { int _id = 0; Vector3 _pos = new Vector3(); Vector3 _dir = new Vector3(); float _hp = 0; inInputStream.Read(ref _id); inInputStream.Read(ref _pos); inInputStream.Read(ref _dir); inInputStream.Read(ref _hp); MonsterManager.instance.SearchMonster(_id, _pos, _dir, _hp); } if (!FistCreateComplete) { OutputMemoryStream os = new OutputMemoryStream(); os.Write((short)Defines.SET_COMPLETE); NetWork.instance.Send(os); FistCreateComplete = true; } } }
public void Send(OutputMemoryStream os) { //추가 정보를 넘기기 위한 변수 선언 AsyncObject ao = new AsyncObject(1); //OutputMemoryStream 사이즈 + short byte[] Header = BitConverter.GetBytes((short)(os.GetDataLength() + sizeof(short))); //OutputMemoryStream 사이즈와 short 2바이트 크기를 잡아서 할당 byte[] packet = new byte[os.GetDataLength() + Header.Length]; //해더 + OutputMemoryStream Array.Copy(Header, 0, packet, 0, Header.Length); Array.Copy(os.GetBuffer(), 0, packet, Header.Length, os.GetDataLength()); ao.Buffer = packet; ao.WorkingSocket = m_ClientSocket; //전송시작 try { //BeginSend : 연결된 Socket 데이터를 비동기로 보낸다 m_ClientSocket.BeginSend(ao.Buffer, 0, ao.Buffer.Length, SocketFlags.None, m_fnSendHandler, ao); } catch (Exception ex) { Debug.Log("전송 중 오류발생" + ex); } }
public void Connet() { NetWork.instance.Connect(); OutputMemoryStream os = new OutputMemoryStream(); os.Write((short)Defines.LOGIN_CHECK); os.Write(id); os.Write(pw); NetWork.instance.Send(os); }
public void Write(PlayerState _PT) { OutputMemoryStream os = new OutputMemoryStream(); os.Write((short)Defines.USER_DATA); os.Write(this.Name); os.Write(tr.position); os.Write(dir); os.Write((short)_PT); NetWork.instance.Send(os); }
public void Write(string name) { if (collisionCheckList.Count != 0) { OutputMemoryStream os = new OutputMemoryStream(); os.Write((short)Defines.CHECK_MONSTERS); os.Write(name); os.Write((short)collisionCheckList.Count); for (int i = 0; i < collisionCheckList.Count; ++i) { os.Write((short)collisionCheckList[i]); } NetWork.instance.Send(os); collisionCheckList.Clear(); } }
/// <summary> /// 千万要记得关闭 /// </summary> /// <param name="name"></param> /// <returns></returns> public override Stream GetEntryOutputStream(string entryPath) { if (string.IsNullOrEmpty(entryPath)) { throw new ArgumentNullException("entryPath"); } var oms = new OutputMemoryStream(entryPath, this.entries); this.entries[entryPath] = oms.ToArray(); return oms; }
protected BaseBinaryWriter() { Stream = new OutputMemoryStream(); }