Esempio n. 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;
 }
Esempio n. 2
0
File: Agent.cs Progetto: vebin/BD2
 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;
 }
Esempio n. 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");
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 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?
 }
Esempio n. 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 ();
 }
Esempio n. 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);
 }
Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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;
		}
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 19
0
 void sessionReady(ObjectBusSession session)
 {
     SendMessage(new BusReadyMessage(session.SessionID));
 }
Esempio n. 20
0
 void sessionReady(ObjectBusSession session)
 {
     SendMessage (new BusReadyMessage (session.SessionID));
 }
Esempio n. 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?
 }
Esempio n. 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);
 }
Esempio n. 23
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
 {
     return new ChatAgent (serviceAgentMode, objectBusSession, flush);
 }
Esempio n. 24
0
 public TransparentAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     this.parameters = parameters;
 }
Esempio n. 25
0
 FileShareAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
     objectBusSession.RegisterType (typeof(FileShareMessage), FileShareMessageReceived);
 }
Esempio n. 26
0
 protected DatabaseConnectionAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
 }
Esempio n. 27
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, Byte[] parameters)
 {
     return new TransparentAgent (serviceAgentMode, objectBusSession, flush, parameters);
 }
Esempio n. 28
0
        void SessionDisconnected(ObjectBusSession session)
        {
            #if TRACE
            Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
            #endif

            lock (sessionAgents)
                sessionAgents [session.SessionID].CallSessionDisconnected ();
        }
Esempio n. 29
0
 ChatAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
     objectBusSession.RegisterType (typeof(ChatMessage), ChatMessageReceived);
 }
Esempio n. 30
0
 public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters)
 {
     return new ServiceAgent (serviceAgentMode, objectBusSession, flush, ServiceParameters.Deserialize (parameters));
 }
Esempio n. 31
0
 public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run)
     : base(serviceAgentMode, objectBusSession, flush, run)
 {
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 34
0
 public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, UserStorageBase userStorage, IEnumerable<byte[]> users)
     : base(serviceAgentMode, objectBusSession, flush, false)
 {
 }