Exemple #1
0
 public BD2ServiceAgent(Database database, ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     if (database == null)
         throw new ArgumentNullException ("database");
     this.database = database;
 }
Exemple #2
0
 public Agent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, ChannelControl channelControl)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     objectBusSession.RegisterType (typeof(GetPublicKeyRequestMessage), GetPublicKeyRequestMessageReceived);
     objectBusSession.RegisterType (typeof(CreateChannelRequestMessage), CreateChannelRequestMessageReceived);
     this.channelControl = channelControl;
 }
Exemple #3
0
 //SortedDictionary<Guid, Column> columns = new SortedDictionary<Guid, Column> ();
 //SortedDictionary<int, SortedDictionary<string,Column>> tableColumns = new SortedDictionary<int, SortedDictionary<string, Column>> ();
 ServiceAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, ServiceParameters parameters)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     if (serviceAgentMode != ServiceAgentMode.Server)
         throw new Exception ("This service agent can only be run in server mode.");
     connectionString = parameters.ConnectionString;
     objectBusSession.RegisterType (typeof(GetTablesRequestMessage), GetTablesRequestMessageReceived);
     objectBusSession.RegisterType (typeof(GetColumnsRequestMessage), GetColumnsRequestMessageReceived);
     objectBusSession.RegisterType (typeof(GetRowsRequestMessage), GetRowsRequestMessageReceived);
     objectBusSession.RegisterType (typeof(GetForeignKeyRelationsRequestMessage), GetForeignKeyRelationsRequestMessageReceived);
     tfqns.Add (48, "System.Byte");
     tfqns.Add (173, "System.Byte[]");
     tfqns.Add (165, "System.Byte[]");
     tfqns.Add (52, "System.Int16");
     tfqns.Add (56, "System.Int32");
     tfqns.Add (127, "System.Int64");
     tfqns.Add (62, "System.Double");
     tfqns.Add (106, "System.Double");
     tfqns.Add (108, "System.Double");
     tfqns.Add (231, "System.String");
     tfqns.Add (239, "System.String");
     tfqns.Add (175, "System.String");
     tfqns.Add (104, "System.Boolean");
     tfqns.Add (34, "System.Byte[]");
     tfqns.Add (36, "System.Guid");
     tfqns.Add (41, "System.DateTime");
     tfqns.Add (42, "System.DateTime");
     tfqns.Add (43, "System.DateTime");
     tfqns.Add (61, "System.DateTime");
 }
Exemple #4
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     return new StreamPairAgent (serviceAgentMode, objectBusSession, flush, true);
 }
Exemple #5
0
 void StreamHandlerCallback(byte[] messageContents)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     if (messageContents == null)
     {
         throw new ArgumentNullException("messageContents");
     }
     if (messageContents.Length < 32)
     {
         throw new ArgumentException("messageContents cannot be less than 16 bytes.");
     }
     byte[] sessionIDBytes = new byte[16];
     System.Buffer.BlockCopy(messageContents, 0, sessionIDBytes, 0, 16);
     Guid             sessionID = new Guid(sessionIDBytes);
     ObjectBusSession session   = null;
     if (sessionID == Guid.Empty)
     {
         session = systemSession;
     }
     else
     {
         lock (sessions)
             session = sessions [sessionID];
     }
     byte[] bytes = new byte[messageContents.Length - 16];
     System.Buffer.BlockCopy(messageContents, 16, bytes, 0, messageContents.Length - 16);
     System.Threading.ThreadPool.QueueUserWorkItem((new tpmessage(streamHandlerCallbackHandlers [session], bytes)).tpcallback);
 }
Exemple #6
0
 StreamPairAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     objectBusSession.RegisterType (typeof(StreamPairMessage), StreamPairMessageReceived);
 }
Exemple #7
0
 void DestroyHandler(ObjectBusSession session)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     ServiceDestroyMessage serviceDestroy = new ServiceDestroyMessage(session.SessionID);
     SendMessage(serviceDestroy);
     DestroySession(serviceDestroy);
 }
Exemple #8
0
 public ObjectBusSession CreateSession(Guid sessionID, Action<ObjectBusSession> sessionDisconnected)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     ObjectBusSession session = new ObjectBusSession (sessionID, SendMessageHandler, RegisterStreamHandlerCallbackHandler, DestroyHandler, sessionDisconnected, sessionReady);
     lock (sessions)
         sessions.Add (sessionID, session);
     return session;
 }
Exemple #9
0
 public ObjectBusSession CreateSession(Guid sessionID, Action <ObjectBusSession> sessionDisconnected)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     ObjectBusSession session = new ObjectBusSession(sessionID, SendMessageHandler, RegisterStreamHandlerCallbackHandler, DestroyHandler, sessionDisconnected, sessionReady);
     lock (sessions)
         sessions.Add(sessionID, session);
     return(session);
 }
Exemple #10
0
 void SystemSessionDisconnected(ObjectBusSession session)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     if (systemSession != session)
     {
         throw new InvalidOperationException();
     }
     //do nothing?
 }
Exemple #11
0
 public ChunkAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, ChunkRepository repository)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     if (repository == null)
         throw new ArgumentNullException ("repository");
     this.repository = repository;
     objectBusSession.RegisterType (typeof(TopLevelChunksRequestMessage), RequestTopLevelChunkDeltaMessageReceived);
     //			objectBusSession.RegisterType (typeof(BD2.Chunk.Daemon.Common.PollChunksRequestMessage), );
     //			objectBusSession.RegisterType (typeof(BD2.Chunk.Daemon.Common.PollNewChunksRequestMessage), );
     //			objectBusSession.RegisterType (typeof(BD2.Chunk.Daemon.Common.PushChunksRequestMessage), );
     //this.repository.Enumerate ();
 }
Exemple #12
0
 void SendMessageHandler(ObjectBusMessage message, ObjectBusSession session)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     byte[] messageBody = message.GetMessageBody();
     byte[] bytes       = new byte[32 + messageBody.Length];
     System.Buffer.BlockCopy(session.SessionID.ToByteArray(), 0, bytes, 0, 16);
     System.Buffer.BlockCopy(message.TypeID.ToByteArray(), 0, bytes, 16, 16);
     System.Buffer.BlockCopy(messageBody, 0, bytes, 32, messageBody.Length);
     streamHandler.SendMessage(bytes);
 }
Exemple #13
0
 public TransparentStreamServer(ServiceAgent agent, System.IO.Stream baseStream, ObjectBusSession objectBusSession)
 {
     if (agent == null)
         throw new ArgumentNullException ("agent");
     if (baseStream == null)
         throw new ArgumentNullException ("baseStream");
     if (objectBusSession == null)
         throw new ArgumentNullException ("objectBusSession");
     this.streamID = Guid.NewGuid ();
     this.agent = agent;
     this.baseStream = baseStream;
     this.objectBusSession = objectBusSession;
 }
Exemple #14
0
 public ObjectBus(StreamHandler streamHandler)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     if (streamHandler == null)
         throw new ArgumentNullException ("streamHandler");
     this.streamHandler = streamHandler;
     streamHandler.RegisterCallback (StreamHandlerCallback);
     streamHandler.RegisterDisconnectHandler (streamHandlerDisconnected);
     systemSession = CreateSession (Guid.Empty, SystemSessionDisconnected);
     RegisterType (typeof(BusReadyMessage), busReadyMessageReceived);
 }
Exemple #15
0
 public ObjectBus(StreamHandler streamHandler)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     if (streamHandler == null)
     {
         throw new ArgumentNullException("streamHandler");
     }
     this.streamHandler = streamHandler;
     streamHandler.RegisterCallback(StreamHandlerCallback);
     streamHandler.RegisterDisconnectHandler(streamHandlerDisconnected);
     systemSession = CreateSession(Guid.Empty, SystemSessionDisconnected);
     RegisterType(typeof(BusReadyMessage), bunReadyMessageReceived);
 }
Exemple #16
0
		internal TransparentStream (ServiceAgent agent, Guid streamID, ObjectBusSession objectBusSession)
		{
			if (agent == null)
				throw new ArgumentNullException ("agent");
			if (objectBusSession == null)
				throw new ArgumentNullException ("objectBusSession");
			this.agent = agent;
			this.streamID = streamID;
			this.objectBusSession = objectBusSession;
		}
Exemple #17
0
 void SendMessageHandler(ObjectBusMessage message, ObjectBusSession session)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     byte[] messageBody = message.GetMessageBody ();
     byte[] bytes = new byte[32 + messageBody.Length];
     System.Buffer.BlockCopy (session.SessionID.ToByteArray (), 0, bytes, 0, 16);
     System.Buffer.BlockCopy (message.TypeID.ToByteArray (), 0, bytes, 16, 16);
     System.Buffer.BlockCopy (messageBody, 0, bytes, 32, messageBody.Length);
     streamHandler.SendMessage (bytes);
 }
Exemple #18
0
 void RegisterStreamHandlerCallbackHandler(Action <byte[]> streamHandlerCallbackHandler, ObjectBusSession session)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     lock (streamHandlerCallbackHandlers)
         streamHandlerCallbackHandlers.Add(session, streamHandlerCallbackHandler);
 }
Exemple #19
0
 void sessionReady(ObjectBusSession session)
 {
     SendMessage(new BusReadyMessage(session.SessionID));
 }
Exemple #20
0
 void sessionReady(ObjectBusSession session)
 {
     SendMessage (new BusReadyMessage (session.SessionID));
 }
Exemple #21
0
 void SystemSessionDisconnected(ObjectBusSession session)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     if (systemSession != session)
         throw new InvalidOperationException ();
     //do nothing?
 }
Exemple #22
0
 void RegisterStreamHandlerCallbackHandler(Action<byte[]> streamHandlerCallbackHandler, ObjectBusSession session)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     lock (streamHandlerCallbackHandlers)
         streamHandlerCallbackHandlers.Add (session, streamHandlerCallbackHandler);
 }
Exemple #23
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
 {
     return new ChatAgent (serviceAgentMode, objectBusSession, flush);
 }
Exemple #24
0
 public TransparentAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     this.parameters = parameters;
 }
Exemple #25
0
 FileShareAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
     objectBusSession.RegisterType (typeof(FileShareMessage), FileShareMessageReceived);
 }
Exemple #26
0
 protected DatabaseConnectionAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
 }
Exemple #27
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, Byte[] parameters)
 {
     return new TransparentAgent (serviceAgentMode, objectBusSession, flush, parameters);
 }
Exemple #28
0
        void SessionDisconnected(ObjectBusSession session)
        {
            #if TRACE
            Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
            #endif

            lock (sessionAgents)
                sessionAgents [session.SessionID].CallSessionDisconnected ();
        }
Exemple #29
0
 ChatAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     objectBusSession.RegisterType (typeof(ChatMessage), ChatMessageReceived);
 }
Exemple #30
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
 {
     return new ServiceAgent (serviceAgentMode, objectBusSession, flush, ServiceParameters.Deserialize (parameters));
 }
Exemple #31
0
 public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
 }
Exemple #32
0
 void DestroyHandler(ObjectBusSession session)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     ServiceDestroyMessage serviceDestroy = new ServiceDestroyMessage (session.SessionID);
     SendMessage (serviceDestroy);
     DestroySession (serviceDestroy);
 }
Exemple #33
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, ChunkRepository repository)
 {
     if (repository == null)
         throw new ArgumentNullException ("repository");
     return new ChunkAgent (serviceAgentMode, objectBusSession, flush, repository);
 }
Exemple #34
0
 public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, UserStorageBase userStorage, IEnumerable<byte[]> users)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
 }