コード例 #1
0
ファイル: ChunkAgent.cs プロジェクト: vebin/BD2
 void RequestTopLevelChunkDeltaMessageReceived(ObjectBusMessage  message)
 {
     if (message == null)
         throw new ArgumentNullException ("message");
     TopLevelChunksRequestMessage requestTopLevelChunkDeltaMessage = (TopLevelChunksRequestMessage)message;
     pendingRemoteRequests.Enqueue (requestTopLevelChunkDeltaMessage);
 }
コード例 #2
0
ファイル: ObjectBus.cs プロジェクト: nGenieDeveloper/BD2
 public void SendMessage(ObjectBusMessage message)
 {
                 #if TRACE
     Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                 #endif
     systemSession.SendMessage(message);
 }
コード例 #3
0
        public void SendMessage(ObjectBusMessage message)
        {
                        #if TRACE
            Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0));
                        #endif

            sendMessageCallback(message, this);
        }
コード例 #4
0
ファイル: ObjectBus.cs プロジェクト: nGenieDeveloper/BD2
 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);
 }
コード例 #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 < 16)
            {
                throw new ArgumentException("messageContents cannot be less than 16 bytes.");
            }
            byte[] messageTypeBytes = new byte[16];
            System.Buffer.BlockCopy(messageContents, 0, messageTypeBytes, 0, 16);
            Guid MessageType = new Guid(messageTypeBytes);
            if (!deserializers.ContainsKey(MessageType))
            {
                throw new Exception(string.Format("Deserializer for object type id '{0}' is not registered", MessageType));
            }
            ObjectBusMessageDeserializerAttribute obmda = deserializers [MessageType];
            byte[] bytes = new byte[messageContents.Length - 16];
            System.Buffer.BlockCopy(messageContents, 16, bytes, 0, messageContents.Length - 16);
            ObjectBusMessage messageObject = obmda.Deserialize(bytes);
            SortedDictionary <string, Action <ObjectBusMessage> > cbs;
            lock (callbacks) {
                cbs = new SortedDictionary <string, Action <ObjectBusMessage> > (callbacks);
            }
            foreach (var ct in cbs)
            {
                if (ct.Key == messageObject.GetType().ToString())
                {
                    ct.Value(messageObject);
                }
            }
        }
コード例 #6
0
ファイル: ObjectBus.cs プロジェクト: nGenieDeveloper/BD2
        void bunReadyMessageReceived(ObjectBusMessage message)
        {
            BusReadyMessage brm = (BusReadyMessage)message;

            sessions [brm.ObjectBusSessionID].setRemoteReady();
        }
コード例 #7
0
ファイル: ServiceAgent.cs プロジェクト: vebin/BD2
        void GetRowsRequestMessageReceived(ObjectBusMessage obj)
        {
            Console.WriteLine ("GetRowsRequestMessageReceived()");
            GetRowsRequestMessage request = (GetRowsRequestMessage)obj;
            GetRowsResponseMessage response;
            Table table;
            lock (tables)
                table = (Table)psc.GetTableByID (request.TableID);
            Console.WriteLine (table.Name);
            try {

                SqlConnection conn_Rows = new SqlConnection (connectionString);
                try {
                    conn_Rows.Open ();
                } catch {                    //retry once
                    conn_Rows.Open ();
                }

                SqlCommand cmdSelect = new SqlCommand (string.Format ("Select * from [{0}]", table.Name), conn_Rows);
                cmdSelect.CommandTimeout *= 30;
                response = new GetRowsResponseMessage (request.ID, readRowsData (conn_Rows, cmdSelect, cmdSelect.ExecuteReader (), table), null);
            } catch (Exception ex) {
                response = new GetRowsResponseMessage (request.ID, new List<BD2.Conv.Frontend.Table.Row> (), ex);
            }
            ObjectBusSession.SendMessage (response);
            Console.WriteLine ("Sent GetRowsResponseMessage.");
        }
コード例 #8
0
ファイル: Agent.cs プロジェクト: vebin/BD2
 public void CreateChannelRequestMessageReceived(ObjectBusMessage message)
 {
 }
コード例 #9
0
ファイル: ServiceManager.cs プロジェクト: vebin/BD2
 void ServiceAnnouncementReceived(ObjectBusMessage message)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     if (message == null)
         throw new ArgumentNullException ("message");
     if (!(message is ServiceAnnounceMessage))
         throw new ArgumentException (string.Format ("message type is not valid, must be of type {0}", typeof(ServiceAnnounceMessage).FullName));
     ServiceAnnounceMessage serviceAnnouncement = (ServiceAnnounceMessage)message;
     lock (remoteServices)
         remoteServices.Add (serviceAnnouncement);
 }
コード例 #10
0
ファイル: StreamPairAgent.cs プロジェクト: vebin/BD2
 void StreamPairMessageReceived(ObjectBusMessage message)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     StreamPairMessage StreamPairMessage = (StreamPairMessage)message;
     Stream stream = OpenStream (StreamPairMessage.StreamID);
     System.IO.BinaryReader BR = new BinaryReader (stream);
     byte[] buf = BR.ReadBytes (BR.ReadInt32 ());
     byte[] hash = System.Security.Cryptography.SHA1.Create ().ComputeHash (buf);
     for (int n = 0; n != hash.Length; n++)
         Console.Write ("{0:X2}", hash [n]);
     Console.WriteLine ();
 }
コード例 #11
0
ファイル: FileShareAgent.cs プロジェクト: vebin/BD2
 void FileShareMessageReceived(ObjectBusMessage message)
 {
     FileShareMessage fileShareMessace = (FileShareMessage)message;
     files.Enqueue (fileShareMessace);
     mre_fileReceived.Set ();
 }
コード例 #12
0
ファイル: ObjectBus.cs プロジェクト: vebin/BD2
 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);
 }
コード例 #13
0
ファイル: ObjectBus.cs プロジェクト: vebin/BD2
 void busReadyMessageReceived(ObjectBusMessage message)
 {
     BusReadyMessage brm = (BusReadyMessage)message;
     sessions [brm.ObjectBusSessionID].setRemoteReady ();
 }
コード例 #14
0
ファイル: ObjectBus.cs プロジェクト: vebin/BD2
 public void SendMessage(ObjectBusMessage message)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     systemSession.SendMessage (message);
 }
コード例 #15
0
ファイル: ServiceAgent.cs プロジェクト: vebin/BD2
 void GetTablesRequestMessageReceived(ObjectBusMessage obj)
 {
     Console.WriteLine ("GetTablesRequestMessageReceived()");
     GetTablesRequestMessage request = (GetTablesRequestMessage)obj;
     GetTablesResponseMessage response;
     try {
         response = new GetTablesResponseMessage (request.ID, (new List<Table> (getTables ())).ToArray (), null);
     } catch (Exception ex) {
         response = new GetTablesResponseMessage (request.ID, new Table[0] { }, ex);
     }
     ObjectBusSession.SendMessage (response);
 }
コード例 #16
0
ファイル: TransparentAgent.cs プロジェクト: vebin/BD2
 public void SendMessage(ObjectBusMessage message)
 {
     if (message == null)
         throw new ArgumentNullException ("message");
     ObjectBusSession.SendMessage (message);
 }
コード例 #17
0
ファイル: ChatAgent.cs プロジェクト: vebin/BD2
 void ChatMessageReceived(ObjectBusMessage message)
 {
     ChatMessage chatMessage = (ChatMessage)message;
     Console.WriteLine (chatMessage.Text);
 }
コード例 #18
0
ファイル: ServiceManager.cs プロジェクト: vebin/BD2
        void ServiceDestroyReceived(ObjectBusMessage message)
        {
            #if TRACE
            Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
            #endif

            if (message == null)
                throw new ArgumentNullException ("message");
            if (!(message is ServiceDestroyMessage)) {
                throw new ArgumentException (string.Format ("message type is not valid, must be of type {0}", typeof(ServiceDestroyMessage).FullName));
            }
            ServiceDestroyMessage serviceDestroy = (ServiceDestroyMessage)message;
            lock (sessionAgents)
                sessionAgents [serviceDestroy.SessionID].CallDestroyRequestReceived ();
            objectBus.DestroySession (serviceDestroy);
        }
コード例 #19
0
ファイル: Agent.cs プロジェクト: vebin/BD2
 public void GetPublicKeyRequestMessageReceived(ObjectBusMessage message)
 {
 }
コード例 #20
0
ファイル: ServiceManager.cs プロジェクト: vebin/BD2
 void ServiceManagerReadyMessageReceived(ObjectBusMessage message)
 {
     System.Threading.Thread.Sleep (100);
     RemoteReady = true;
 }
コード例 #21
0
ファイル: ServiceManager.cs プロジェクト: vebin/BD2
        void ServiceRequestReceived(ObjectBusMessage message)
        {
            #if TRACE
            Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
            #endif

            if (message == null)
                throw new ArgumentNullException ("message");
            if (!(message is ServiceRequestMessage))
                throw new ArgumentException (string.Format ("message type is not valid, must be of type {0}", typeof(ServiceRequestMessage).FullName));
            ServiceRequestMessage serviceRequest = (ServiceRequestMessage)message;
            Func<ServiceAgentMode , ObjectBusSession, Action, Byte[], ServiceAgent> agentFunc;
            lock (localServices)
            lock (localServiceAgents)
                agentFunc = localServiceAgents [localServices [serviceRequest.ServiceID]];
            Guid responseID = Guid.NewGuid ();
            ObjectBusSession session = objectBus.CreateSession (responseID, SessionDisconnected);
            ServiceResponseMessage response = new ServiceResponseMessage (responseID, serviceRequest.ID, ServiceResponseStatus.Accepted);
            ServiceAgent agent = agentFunc.Invoke (ServiceAgentMode.Server, session, objectBus.Flush, serviceRequest.Parameters);
            lock (sessionAgents)
                sessionAgents.Add (session.SessionID, agent);
            objectBus.SendMessage (response);
        }
コード例 #22
0
ファイル: ServiceManager.cs プロジェクト: vebin/BD2
 void ServiceResponseReceived(ObjectBusMessage message)
 {
     #if TRACE
     Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
     #endif
     if (message == null)
         throw new ArgumentNullException ("message");
     if (!(message is ServiceResponseMessage))
         throw new ArgumentException (string.Format ("message type is not valid, must be of type {0}", typeof(ServiceResponseMessage).FullName));
     ServiceResponseMessage serviceResponse = (ServiceResponseMessage)message;
     Tuple<ServiceRequestMessage, System.Threading.ManualResetEvent, System.Threading.ManualResetEvent> requestTuple = requests [serviceResponse.RequestID];
     lock (pendingResponses)
         pendingResponses.Add (serviceResponse.RequestID, serviceResponse);
     requestTuple.Item2.Set ();
     requestTuple.Item3.WaitOne ();
 }
コード例 #23
0
ファイル: ObjectBusSession.cs プロジェクト: vebin/BD2
        public void SendMessage(ObjectBusMessage message)
        {
            #if TRACE
            Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0));
            #endif

            sendMessageCallback (message, this);
        }
コード例 #24
0
ファイル: ServiceAgent.cs プロジェクト: vebin/BD2
 void GetColumnsRequestMessageReceived(ObjectBusMessage obj)
 {
     Console.WriteLine ("GetColumnsRequestMessageReceived()");
     GetColumnsRequestMessage request = (GetColumnsRequestMessage)obj;
     GetColumnsResponseMessage response;
     Table table;
     try {
         lock (tables)
             table = (Table)psc.GetTableByID (request.TableID);
         response = new GetColumnsResponseMessage (request.ID, (new List <Column> (getColumns (table.SqlTableID))).ToArray (), null);
     } catch (Exception ex) {
         response = new GetColumnsResponseMessage (request.ID, new Column[0] { }, ex);
     }
     ObjectBusSession.SendMessage (response);
 }