From 19d0dfc7b655b7f3c8c6a9edd751d8e2342b9ae0 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:50:31 +0000 Subject: Utilisateur : Fcolin Date : 1/12/05 Heure : 17:47 Archivé dans $/CSharp/Ivy Commentaire: (vss 4) --- CSharp/Ivy/Ivy/IvyTCPStreamV4.cs | 56 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'CSharp/Ivy') diff --git a/CSharp/Ivy/Ivy/IvyTCPStreamV4.cs b/CSharp/Ivy/Ivy/IvyTCPStreamV4.cs index d146632..1fead5a 100644 --- a/CSharp/Ivy/Ivy/IvyTCPStreamV4.cs +++ b/CSharp/Ivy/Ivy/IvyTCPStreamV4.cs @@ -10,11 +10,11 @@ namespace IvyBus /// /// Description résumée de IvyStream. /// - public class IvyTCPStream : NetworkStream + public class IvyTCPStreamV4 : NetworkStream { BinaryReader input; BinaryWriter output; - public IvyTCPStream(Socket socket) : base( socket, true ) + public IvyTCPStreamV4(Socket socket) : base( socket, true ) { input = new BinaryReader( new BufferedStream(this),Encoding.ASCII); output = new BinaryWriter( new BufferedStream(this), Encoding.ASCII); @@ -44,7 +44,7 @@ namespace IvyBus * message Format: MessageType, id , length, string */ - internal void sendMsg(MessageType type, int id, byte[] arg) + private void sendMsg(MessageType type, int id, byte[] arg) { try { @@ -60,6 +60,56 @@ namespace IvyBus Console.Error.WriteLine(ie.StackTrace); } } + internal void sendStartRegexp(int port, string appName) + { + sendMsg(MessageType.StartRegexp, port, Encoding.ASCII.GetBytes(appName)); + } + internal void sendEndRegexp() + { + sendMsg(MessageType.EndRegexp, 0, Encoding.ASCII.GetBytes("")); + } + internal void sendApplicationId(int priority, string appId) + { + sendMsg(MessageType.ApplicationId, priority, Encoding.ASCII.GetBytes(appId)); + } + + internal void sendBinding(Ivy.ApplicationBinding bind) + { + sendMsg(bind.type == Ivy.BindingType.BindRegexp ? IvyTCPStreamV4.MessageType.AddRegexp : IvyTCPStreamV4.MessageType.AddBinding, bind.key, Encoding.ASCII.GetBytes(bind.regexp)); /* perhaps we should perform some checking here */ + } + + internal void delBinding(Ivy.ApplicationBinding bind) + { + sendMsg(bind.type == Ivy.BindingType.BindRegexp ? IvyTCPStreamV4.MessageType.DelRegexp : IvyTCPStreamV4.MessageType.DelBinding, bind.key, Encoding.ASCII.GetBytes("")); + } + + internal void sendDirectMsg(int id, string message) + { + sendMsg(MessageType.DirectMsg, id, Encoding.ASCII.GetBytes(message)); + } + internal void sendPong(byte[] s) + { + sendMsg(MessageType.Pong, 0, s); + } + internal void sendPing(string s) + { + sendMsg(MessageType.Ping, 0, Encoding.ASCII.GetBytes(s)); + } + + internal void sendBye(string message) + { + sendMsg(MessageType.Bye, 0, Encoding.ASCII.GetBytes(message)); + } + + internal void sendDie(string message) + { + sendMsg(MessageType.Die, 0, Encoding.ASCII.GetBytes(message)); + } + + internal void sendMsg(int key, IvyArgument args) + { + sendMsg(MessageType.Msg, key, args.Serialize() ); + } internal bool receiveMsg(out MessageType type, out int id, out byte[] data) { int length = 0; -- cgit v1.1