public void ExecuteTriggerActions(MessageBody message, Action resumeHook, IActionExecutionContext context) { var triggersToHandle = from trigger in context.Triggers.OfType<IMessageTrigger>() where this.handleMessageTrigger.MeetsCriteria(trigger, message) select trigger; var triggersToExecute = triggersToHandle.ToArray(); foreach (var messageTrigger in triggersToExecute) { messageTrigger.ExecuteBefore(context); } resumeHook(); foreach (var messageTrigger in triggersToExecute) { messageTrigger.ExecuteAfter(context); } }
public void Send(MessageBody message) { throw new NotImplementedException(); }
public void Send(MessageBody message) { Contract.Requires<ArgumentNullException>(message != null); throw new NotImplementedException(); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> /// <param name="dontSend"> /// </param> public void AnnounceOthers(MessageBody messageBody, Identity dontSend) { foreach (IInstancedEntity entity in this.Entities) { var character = entity as Character; if (character != null) { if (character.Identity != dontSend) { character.Send(messageBody); } } } }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendInitiateCompressionMessage(MessageBody messageBody) { // TODO: Investigate if reciever is a timestamp Contract.Requires(messageBody != null); var message = new Message { Body = messageBody, Header = new Header { MessageId = 0xdfdf, PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = 0x03000000, Receiver = this.character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); #if DEBUG Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(NiceHexOutput.Output(buffer)); Console.ResetColor(); LogUtil.Debug(NiceHexOutput.Output(buffer)); #endif this.packetNumber = 1; this.Send(buffer); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> /// <param name="announceToPlayfield"> /// </param> /// <exception cref="NotImplementedException"> /// </exception> public void Send(MessageBody messageBody, bool announceToPlayfield) { if (!announceToPlayfield) { this.Send(messageBody); return; } this.Playfield.Announce(messageBody); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendCompressed(MessageBody messageBody) { Contract.Requires(messageBody != null); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendCompressed(MessageBody messageBody) { if ((this.controller == null) || (this.controller.Character == null)) { return; } var message = new Message { Body = messageBody, Header = new Header { MessageId = BitConverter.ToUInt16(new byte[] { 0xDF, 0xDF }, 0), PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = this.server.Id, Receiver = this.Controller.Character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); lock (this.sendQueue) { this.sendQueue.Enqueue(buffer); } LogUtil.Debug(DebugInfoDetail.AoTomation, messageBody.GetType().ToString()); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendInitiateCompressionMessage(MessageBody messageBody) { // TODO: Investigate if reciever is a timestamp var message = new Message { Body = messageBody, Header = new Header { MessageId = 0xdfdf, PacketType = messageBody.PacketType, Unknown = 0x0001, // TODO: Make compression choosable in config.xml Sender = 0x01000000, // 01000000 = uncompressed, 03000000 = compressed Receiver = 0 // this.character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); if (Program.DebugNetwork) { LogUtil.Debug(NiceHexOutput.Output(buffer)); } this.packetNumber = 1; this.Send(buffer); // Now create the compressed stream try { if (!this.zStreamSetup) { // CreateIM the zStream this.netStream = new NetworkStream(this.TcpSocket); this.zStream = new ZOutputStream(this.netStream, zlibConst.Z_BEST_SPEED); this.zStream.FlushMode = zlibConst.Z_SYNC_FLUSH; this.zStreamSetup = true; } } catch (Exception e) { LogUtil.ErrorException(e); } }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendCompressed(MessageBody messageBody) { var message = new Message { Body = messageBody, Header = new Header { MessageId = BitConverter.ToUInt16(new byte[] { 0xDF, 0xDF }, 0), PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = this.server.Id, Receiver = this.Character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); if (Program.DebugNetwork) { LogUtil.Debug(messageBody.GetType().ToString()); } this.SendCompressed(buffer); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> internal void Send(MessageBody messageBody) { Contract.Requires(messageBody != null); this.client.SendCompressed(messageBody); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendInitiateCompressionMessage(MessageBody messageBody) { // TODO: Investigate if reciever is a timestamp var message = new Message { Body = messageBody, Header = new Header { MessageId = 0xdfdf, PacketType = messageBody.PacketType, Unknown = 0x0001, // TODO: Make compression choosable in config.xml Sender = 0x01000000, // 01000000 = uncompressed, 03000000 = compressed Receiver = 0 // this.character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); LogUtil.Debug(DebugInfoDetail.Network, HexOutput.Output(buffer)); this.packetNumber = 1; this.Send(buffer); // Now create the compressed stream try { if (!this.zStreamSetup) { // CreateIM the zStream this.netStream = new NetworkStream(this.TcpSocket); this.zStream = new ZlibStream(this.netStream, CompressionMode.Compress, CompressionLevel.BestSpeed); this.zStream.FlushMode = FlushType.Sync; this.zStreamSetup = true; } } catch (Exception e) { LogUtil.ErrorException(e); } }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> internal void Send(MessageBody messageBody) { this.Playfield.Send(this.Client, messageBody); }
/// <summary> /// </summary> /// <param name="receiver"> /// </param> /// <param name="messageBody"> /// </param> public void Send(int receiver, MessageBody messageBody) { // TODO: Investigate if reciever is a timestamp var message = new Message { Body = messageBody, Header = new Header { MessageId = BitConverter.ToUInt16(new byte[] { 0xDF, 0xDF }, 0), PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = 0x00000001, Receiver = receiver } }; byte[] buffer = this.messageSerializer.Serialize(message); buffer[0] = BitConverter.GetBytes(this.packetNumber)[0]; buffer[1] = BitConverter.GetBytes(this.packetNumber)[1]; this.packetNumber++; #if DEBUG Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(NiceHexOutput.Output(buffer)); Console.ResetColor(); LogUtil.Debug("Sent:\r\n" + NiceHexOutput.Output(buffer)); #endif if (buffer.Length % 4 > 0) { Array.Resize(ref buffer, buffer.Length + (4 - (buffer.Length % 4))); } this.Send(buffer); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="messages"> /// </param> /// <returns> /// </returns> public static IMSendAOtomationMessageBodiesToClient CreateIM(IZoneClient client, MessageBody[] messages) { return new IMSendAOtomationMessageBodiesToClient() { Bodies = messages, client = client }; }
public void ExecuteTriggerActions(MessageBody message, Action resumeHook, IActionExecutionContext context) { Contract.Requires<ArgumentNullException>(message != null); Contract.Requires<ArgumentNullException>(resumeHook != null); Contract.Requires<ArgumentNullException>(context != null); }
public void Send(MessageBody message) { this.remoteProcess.Send(message); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendInitiateCompressionMessage(MessageBody messageBody) { // IMPORTANT!!!! // DO NOT mess with this packet unless you're 9000% sure you know what you're doing. // This is NOT N3 message, but a special message type. // This is NOT fire and forget packet. // This is a negotiating packet which means that client and server have to agree on values. // out of sync = no go // What is hardcoded here is a working version. Changing this may break things. // ~Midian var comressionNegotiatePacket = new byte[] { 0xdf, 0xdf, 0x7f, 0x00, 0x00, 0x01, 0x00, 0x10, 0x01, 0x00, // RecvCompression 0x01,0x00 Yes/0x00,0x00 No 0x00, 0x00, // SendCompression 0x01,0x00 Yes/0x00,0x00 No 0x00, 0x00, 0x00, 0x00 }; this.Send(comressionNegotiatePacket); this.packetNumber = 1; // TODO: Make compression choosable in config.xml /* var message = new Message { Body = messageBody, Header = new Header { MessageId = 0xdfdf, PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = 0x01000000, // 01000000 = uncompressed, 03000000 = compressed Receiver = 0 // this.character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); LogUtil.Debug(DebugInfoDetail.Network, HexOutput.Output(buffer)); this.Send(buffer); */ // Now create the compressed stream try { if (!this.zStreamSetup) { // CreateIM the zStream this.netStream = new NetworkStream(this.TcpSocket); this.zStream = new ZlibStream(this.netStream, CompressionMode.Compress, CompressionLevel.BestSpeed); this.zStream.FlushMode = FlushType.Sync; this.zStreamSetup = true; } } catch (Exception e) { LogUtil.ErrorException(e); } }
public void Send(MessageBody message) { if (this.client == null) { return; } var clientId = this.player != null ? this.player.RemoteId : Identity.None; this.client.Send(clientId, message); }
/// <summary> /// </summary> /// <param name="receiver"> /// </param> /// <param name="messageBody"> /// </param> public void Send(int receiver, MessageBody messageBody) { // TODO: Investigate if reciever is a timestamp var message = new Message { Body = messageBody, Header = new Header { MessageId = BitConverter.ToUInt16(new byte[] { 0xDF, 0xDF }, 0), PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = 0x00000001, Receiver = receiver } }; byte[] buffer = this.messageSerializer.Serialize(message); buffer[0] = BitConverter.GetBytes(this.packetNumber)[0]; buffer[1] = BitConverter.GetBytes(this.packetNumber)[1]; this.packetNumber++; LogUtil.Debug(DebugInfoDetail.Network, "Sent:\r\n" + HexOutput.Output(buffer)); if (buffer.Length % 4 > 0) { Array.Resize(ref buffer, buffer.Length + (4 - (buffer.Length % 4))); } this.Send(buffer); }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void Announce(MessageBody messageBody) { foreach (IInstancedEntity entity in this.Entities) { var character = entity as Character; if (character != null) { character.Send(messageBody); } } }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void Send(MessageBody messageBody) { if (this.Controller != null) { if (this.Controller.Client != null) { this.Controller.Client.SendCompressed(messageBody); } } }
/// <summary> /// </summary> /// <param name="messageBody"> /// </param> public void SendCompressed(MessageBody messageBody) { #if DEBUG Console.WriteLine("Sending Message: " + messageBody.GetType()); #endif var message = new Message { Body = messageBody, Header = new Header { MessageId = this.packetNumber, PacketType = messageBody.PacketType, Unknown = 0x0001, Sender = 0x00000001, Receiver = this.character.Identity.Instance } }; byte[] buffer = this.messageSerializer.Serialize(message); if ((buffer == null) || (buffer.Length < 1)) { throw new NullReferenceException("Serializer failure? (" + typeof(MessageBody).FullName + ")"); } this.SendCompressed(buffer); }