/// <summary> /// Sends a scene request to the remote peer. /// </summary> /// <param name="sceneIndex"></param> /// <param name="route"></param> /// <param name="writer"></param> /// <param name="priority"></param> /// <param name="reliability"></param> public void SendToScene(byte sceneIndex, ushort route, Action <System.IO.Stream> writer, Stormancer.Core.PacketPriority priority, Stormancer.Core.PacketReliability reliability) { if (writer == null) { throw new ArgumentNullException("writer"); } var stream = new BitStream(); var s = new BSStream(stream); s.WriteByte(sceneIndex); s.Write(BitConverter.GetBytes(route), 0, 2); writer(s); char channel = (char)0; if (reliability == Core.PacketReliability.RELIABLE_SEQUENCED || reliability == Core.PacketReliability.UNRELIABLE_SEQUENCED) { channel = GetChannel(sceneIndex, route); } var result = _rakPeer.Send(stream, (RakNet.PacketPriority)priority, (RakNet.PacketReliability)reliability, channel, this.Guid, false); if (result == 0) { throw new InvalidOperationException("Failed to send message."); } }
private void SendRaw(Action <Stream> writer, Stormancer.Core.PacketPriority priority, Stormancer.Core.PacketReliability reliability, char channel) { var stream = new BitStream(); writer(new BSStream(stream)); var result = _rakPeer.Send(stream, (RakNet.PacketPriority)priority, (RakNet.PacketReliability)reliability, channel, this.Guid, false); if (result == 0) { throw new InvalidOperationException("Failed to send message."); } }