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; }
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; }
//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"); }
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); }
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); }
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); }
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); }
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; }
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); }
void SystemSessionDisconnected(ObjectBusSession session) { #if TRACE Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0)); #endif if (systemSession != session) { throw new InvalidOperationException(); } //do nothing? }
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 (); }
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); }
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; }
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); }
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); }
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; }
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); }
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); }
void sessionReady(ObjectBusSession session) { SendMessage(new BusReadyMessage(session.SessionID)); }
void sessionReady(ObjectBusSession session) { SendMessage (new BusReadyMessage (session.SessionID)); }
void SystemSessionDisconnected(ObjectBusSession session) { #if TRACE Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0)); #endif if (systemSession != session) throw new InvalidOperationException (); //do nothing? }
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); }
public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters) { return new ChatAgent (serviceAgentMode, objectBusSession, flush); }
public TransparentAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters) : base(serviceAgentMode, objectBusSession, flush, false) { this.parameters = parameters; }
FileShareAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run) : base(serviceAgentMode, objectBusSession, flush, run) { objectBusSession.RegisterType (typeof(FileShareMessage), FileShareMessageReceived); }
protected DatabaseConnectionAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run) : base(serviceAgentMode, objectBusSession, flush, run) { }
public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, Byte[] parameters) { return new TransparentAgent (serviceAgentMode, objectBusSession, flush, parameters); }
void SessionDisconnected(ObjectBusSession session) { #if TRACE Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0)); #endif lock (sessionAgents) sessionAgents [session.SessionID].CallSessionDisconnected (); }
ChatAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush) : base(serviceAgentMode, objectBusSession, flush, false) { objectBusSession.RegisterType (typeof(ChatMessage), ChatMessageReceived); }
public static ServiceAgent CreateAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, byte[] parameters) { return new ServiceAgent (serviceAgentMode, objectBusSession, flush, ServiceParameters.Deserialize (parameters)); }
public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, bool run) : base(serviceAgentMode, objectBusSession, flush, run) { }
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); }
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); }
public UserStorageAgent(ServiceAgentMode serviceAgentMode, ObjectBusSession objectBusSession, Action flush, UserStorageBase userStorage, IEnumerable<byte[]> users) : base(serviceAgentMode, objectBusSession, flush, false) { }