From 5095b20e70f331c885ed8147c1a585981ca47884 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:46:41 +0000 Subject: Utilisateur : Fcolin Date : 30/11/05 Heure : 10:27 Archivé dans $/CSharp/Ivy Commentaire: (vss 23) --- CSharp/Ivy/Ivy/IvyClient.cs | 58 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'CSharp') diff --git a/CSharp/Ivy/Ivy/IvyClient.cs b/CSharp/Ivy/Ivy/IvyClient.cs index 3ea460c..b236c7e 100644 --- a/CSharp/Ivy/Ivy/IvyClient.cs +++ b/CSharp/Ivy/Ivy/IvyClient.cs @@ -86,7 +86,7 @@ namespace IvyBus private Ivy bus; private Socket socket; - private IvyStream stream; + private IvyTCPStream stream; private Hashtable bindings; private int appPort; private string clientId; /* an unique ID for each IvyClient */ @@ -111,7 +111,7 @@ namespace IvyBus this.socket = socket; socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.KeepAlive, 1 ); - stream = new IvyStream( socket ); + stream = new IvyTCPStream( socket ); clientPriority = Ivy.DEFAULT_PRIORITY; @@ -121,7 +121,7 @@ namespace IvyBus // the ID is the couple "host name,application Port", the host name // information is in the socket itself, the port is not known if we // initiate the connexion - stream.sendMsg(IvyStream.MessageType.StartRegexp, bus.applicationPort, Encoding.ASCII.GetBytes( bus.appName )); + stream.sendMsg(IvyTCPStream.MessageType.StartRegexp, bus.applicationPort, Encoding.ASCII.GetBytes( bus.appName )); // sends our regexps to the peer lock( bus.bindings.SyncRoot ) { @@ -130,7 +130,7 @@ namespace IvyBus sendBinding(bind); } } - stream.sendMsg(IvyStream.MessageType.EndRegexp, 0, Encoding.ASCII.GetBytes("")); + stream.sendMsg(IvyTCPStream.MessageType.EndRegexp, 0, Encoding.ASCII.GetBytes("")); // spawns a thread to manage the incoming traffic on this // socket. We should be ready to receive messages now. clientThread = new Thread(new ThreadStart(this.Run)); @@ -152,17 +152,17 @@ namespace IvyBus /// internal void sendApplicationId() { - stream.sendMsg( IvyStream.MessageType.ApplicationId, bus.applicationPriority, Encoding.ASCII.GetBytes( bus.AppId ) ); + stream.sendMsg( IvyTCPStream.MessageType.ApplicationId, bus.applicationPriority, Encoding.ASCII.GetBytes( bus.AppId ) ); } internal void sendBinding(Ivy.ApplicationBinding bind) { - stream.sendMsg(bind.type == Ivy.BindingType.BindRegexp ? IvyStream.MessageType.AddRegexp: IvyStream.MessageType.AddBinding, bind.key, Encoding.ASCII.GetBytes( bind.regexp )); /* perhaps we should perform some checking here */ + stream.sendMsg(bind.type == Ivy.BindingType.BindRegexp ? IvyTCPStream.MessageType.AddRegexp: IvyTCPStream.MessageType.AddBinding, bind.key, Encoding.ASCII.GetBytes( bind.regexp )); /* perhaps we should perform some checking here */ } internal void delBinding(Ivy.ApplicationBinding bind) { - stream.sendMsg(bind.type == Ivy.BindingType.BindRegexp ? IvyStream.MessageType.DelRegexp: IvyStream.MessageType.DelBinding, bind.key, Encoding.ASCII.GetBytes( "" )); + stream.sendMsg(bind.type == Ivy.BindingType.BindRegexp ? IvyTCPStream.MessageType.DelRegexp: IvyTCPStream.MessageType.DelBinding, bind.key, Encoding.ASCII.GetBytes( "" )); } /// sends a direct message to the peer /// @@ -175,7 +175,7 @@ namespace IvyBus { try { - stream.sendMsg(IvyStream.MessageType.DirectMsg, id, Encoding.ASCII.GetBytes( message ) ); + stream.sendMsg(IvyTCPStream.MessageType.DirectMsg, id, Encoding.ASCII.GetBytes( message ) ); } catch (IOException e) { @@ -241,7 +241,7 @@ namespace IvyBus IvyArgument args = bind.Match(message); if (args!=null) { - stream.sendMsg(IvyStream.MessageType.Msg, bind.key, args.Serialize()); + stream.sendMsg(IvyTCPStream.MessageType.Msg, bind.key, args.Serialize()); count++; } } @@ -283,7 +283,7 @@ namespace IvyBus /// private void Run() { - IvyStream.MessageType type; + IvyTCPStream.MessageType type; int id; byte[] data; int length; @@ -524,62 +524,62 @@ namespace IvyBus { traceDebug("Ping msg from " + appName + " : " + arg); } - private void DispatchMsg(IvyStream.MessageType msgType, int msgId, byte[] msgData) + private void DispatchMsg(IvyTCPStream.MessageType msgType, int msgId, byte[] msgData) { string strarg = Encoding.ASCII.GetString( msgData ); switch (msgType) { - case IvyStream.MessageType.Die: + case IvyTCPStream.MessageType.Die: recvDie( msgId, strarg ); break; - case IvyStream.MessageType.Bye: + case IvyTCPStream.MessageType.Bye: recvBye( msgId, strarg ); break; - case IvyStream.MessageType.AddRegexp: + case IvyTCPStream.MessageType.AddRegexp: recvAddRegexp( msgId, strarg ); break; - case IvyStream.MessageType.DelRegexp: + case IvyTCPStream.MessageType.DelRegexp: recvDelRegexp( msgId, strarg ); break; - case IvyStream.MessageType.AddBinding: + case IvyTCPStream.MessageType.AddBinding: recvAddBinding( msgId, strarg ); break; - case IvyStream.MessageType.DelBinding: + case IvyTCPStream.MessageType.DelBinding: recvDelBinding( msgId, strarg ); break; - case IvyStream.MessageType.EndRegexp: + case IvyTCPStream.MessageType.EndRegexp: recvEndRegexp( msgId, strarg ); break; - case IvyStream.MessageType.Msg: + case IvyTCPStream.MessageType.Msg: recvMsg( msgId, msgData ); break; - case IvyStream.MessageType.Pong: + case IvyTCPStream.MessageType.Pong: recvPong( msgId, msgData ); break; - case IvyStream.MessageType.Ping: + case IvyTCPStream.MessageType.Ping: recvPing( msgId, msgData ); break; - case IvyStream.MessageType.Error: + case IvyTCPStream.MessageType.Error: recvError( msgId, strarg ); break; - case IvyStream.MessageType.StartRegexp: + case IvyTCPStream.MessageType.StartRegexp: recvStartRegexp( msgId, strarg ); break; - case IvyStream.MessageType.DirectMsg: + case IvyTCPStream.MessageType.DirectMsg: recvDirectMsg( msgId, msgData ); break; - case IvyStream.MessageType.ApplicationId: + case IvyTCPStream.MessageType.ApplicationId: recvApplicationId( msgId, strarg ); break; default: @@ -590,21 +590,21 @@ namespace IvyBus private void sendPong(byte[] s) { - stream.sendMsg(IvyStream.MessageType.Pong, 0, s); + stream.sendMsg(IvyTCPStream.MessageType.Pong, 0, s); } public void sendPing(string s) { - stream.sendMsg(IvyStream.MessageType.Ping, 0, Encoding.ASCII.GetBytes(s)); + stream.sendMsg(IvyTCPStream.MessageType.Ping, 0, Encoding.ASCII.GetBytes(s)); } private void sendBye(string message) { - stream.sendMsg(IvyStream.MessageType.Bye, 0, Encoding.ASCII.GetBytes( message )); + stream.sendMsg(IvyTCPStream.MessageType.Bye, 0, Encoding.ASCII.GetBytes( message )); } public void sendDie(string message) { - stream.sendMsg(IvyStream.MessageType.Die, 0, Encoding.ASCII.GetBytes( message ) ); + stream.sendMsg(IvyTCPStream.MessageType.Die, 0, Encoding.ASCII.GetBytes( message ) ); } -- cgit v1.1