diff options
Diffstat (limited to 'CSharp')
-rw-r--r-- | CSharp/Ivy/Ivy/IvyTCPStreamV4.cs | 56 |
1 files changed, 53 insertions, 3 deletions
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 /// <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;
|