void RequestTopLevelChunkDeltaMessageReceived(ObjectBusMessage message) { if (message == null) throw new ArgumentNullException ("message"); TopLevelChunksRequestMessage requestTopLevelChunkDeltaMessage = (TopLevelChunksRequestMessage)message; pendingRemoteRequests.Enqueue (requestTopLevelChunkDeltaMessage); }
public void SendMessage(ObjectBusMessage message) { #if TRACE Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0)); #endif systemSession.SendMessage(message); }
public void SendMessage(ObjectBusMessage message) { #if TRACE Console.WriteLine(new System.Diagnostics.StackTrace(true).GetFrame(0)); #endif sendMessageCallback(message, this); }
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 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); } } }
void bunReadyMessageReceived(ObjectBusMessage message) { BusReadyMessage brm = (BusReadyMessage)message; sessions [brm.ObjectBusSessionID].setRemoteReady(); }
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."); }
public void CreateChannelRequestMessageReceived(ObjectBusMessage message) { }
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); }
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 (); }
void FileShareMessageReceived(ObjectBusMessage message) { FileShareMessage fileShareMessace = (FileShareMessage)message; files.Enqueue (fileShareMessace); mre_fileReceived.Set (); }
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 busReadyMessageReceived(ObjectBusMessage message) { BusReadyMessage brm = (BusReadyMessage)message; sessions [brm.ObjectBusSessionID].setRemoteReady (); }
public void SendMessage(ObjectBusMessage message) { #if TRACE Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0)); #endif systemSession.SendMessage (message); }
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); }
public void SendMessage(ObjectBusMessage message) { if (message == null) throw new ArgumentNullException ("message"); ObjectBusSession.SendMessage (message); }
void ChatMessageReceived(ObjectBusMessage message) { ChatMessage chatMessage = (ChatMessage)message; Console.WriteLine (chatMessage.Text); }
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); }
public void GetPublicKeyRequestMessageReceived(ObjectBusMessage message) { }
void ServiceManagerReadyMessageReceived(ObjectBusMessage message) { System.Threading.Thread.Sleep (100); RemoteReady = true; }
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); }
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 (); }
public void SendMessage(ObjectBusMessage message) { #if TRACE Console.WriteLine (new System.Diagnostics.StackTrace (true).GetFrame (0)); #endif sendMessageCallback (message, this); }
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); }