public void DenyFile(string fileName, uint transferId) { StreamReliable.WriteUShort((ushort)ENetCommand.NetFile); StreamReliable.WriteUInt(transferId); StreamReliable.WriteString(fileName); StreamReliable.WriteByte(0); }
public override bool WriteToBuffer(BufferWrite buffer) { buffer.WriteByte((byte)_state); return(true); }
public int SendDatagram(BufferWrite datagram) { var send = new BufferWrite(); send.WriteInt(_outSequenceNr); send.WriteInt(_inSequenceNr); send.WriteByte(_inReliableState); var flagsPos = send.Position; // write correct flags value later send.WriteByte(0); byte flags = 0; if (_chokedPackets > 0) { flags |= (byte)ENetPacketHeader.Choked; send.WriteByte((byte)(_chokedPackets & 0xFF)); } if (datagram != null) { if (datagram.GetNumBitsWritten() > 0) { send.WriteBytes(datagram.GetData()); } } if (StreamUnreliable.GetNumBitsWritten() > 0) { send.WriteBytes(StreamUnreliable.GetData()); } // clear unreliable data buffer StreamUnreliable.Reset(); send.WriteByteAt((int)flagsPos, flags); var bytesSend = Networking.SendPacket(this, _socket, _remoteAddress, send.GetData()); // TODO: Calc sended size with udp header, and retreive stats // TODO: Network throttling if (_clearTime < Networking.NetTime) { _clearTime = Networking.NetTime; } var addTime = bytesSend / _rate; _clearTime += addTime; if (Networking.NetMaxcleartime > 0.0f) { var latestClearTime = Networking.NetTime + Networking.NetMaxcleartime; if (_clearTime > latestClearTime) { _clearTime = latestClearTime; } } _chokedPackets = 0; _outSequenceNr++; // return send sequence nr return(_outSequenceNr - 1); }