public static void HandleBytes(Session Session, ref byte[] Bytes) { if (Encoding.ASCII.GetString(Bytes) == "<policy-file-request/>\x0") { Session.Send(PolicyFileRequest); return; } var Pointer = new int(); try { for (; Pointer < Bytes.Length; ) { var MessageLength = Base64Encoding.DecodeInt32(new byte[] { Bytes[Pointer++], Bytes[Pointer++], Bytes[Pointer++] }); var MessageId = Base64Encoding.DecodeInt32(new byte[] { Bytes[Pointer++], Bytes[Pointer++] }); var ContextLength = (MessageLength - 2); var Context = new byte[ContextLength]; Array.Copy(Bytes, Pointer, Context, 0, ContextLength); Pointer += ContextLength; var InMessage = new InMessage(MessageId, Context); HandleEvent(Session, InMessage); } } catch { } }
public static void HandleComposer(Session Session, IMessageComposer Composer, params object[] Parameters) { var Bytes = Composer.Invoke(Parameters).Result; if (Bytes.Count() > 0) { Session.Send(Bytes); } }