diff options
author | fcolin | 2007-02-01 10:02:20 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 10:02:20 +0000 |
commit | 433b00c556ddff4b86e4c97dc4e63675f9aaec78 (patch) | |
tree | 3b852e0157ab5dc9f440c8ac0a5e50355ae68c79 /CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs | |
parent | a4b200202c81f802b5430dc4405080111b3982a4 (diff) | |
download | ivy-csharp-433b00c556ddff4b86e4c97dc4e63675f9aaec78.zip ivy-csharp-433b00c556ddff4b86e4c97dc4e63675f9aaec78.tar.gz ivy-csharp-433b00c556ddff4b86e4c97dc4e63675f9aaec78.tar.bz2 ivy-csharp-433b00c556ddff4b86e4c97dc4e63675f9aaec78.tar.xz |
Utilisateur : Fcolin Date : 1/12/05 Heure : 17:47 Archivé dans $/CSharp/Ivy Commentaire: (vss 4)
Diffstat (limited to 'CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs')
-rw-r--r-- | CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs b/CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs index d146632..1fead5a 100644 --- a/CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs +++ b/CSharp/Ivy/IvyPPC/IvyTCPStreamV4.cs @@ -10,11 +10,11 @@ namespace IvyBus /// <summary>
/// Description résumée de IvyStream.
/// </summary>
- 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;
|