Ejemplo n.º 1
0
        public MessageEventArgs(byte[] msg, string endOfMessage)
        {
            try
            {
                string beginning = Encoding.UTF8.GetString(msg.Take(5).ToArray());

                if (beginning == "<BOF>" && endOfMessage == "<EOF>")
                {
                    byte[] data = new byte[msg.Length - 10];
                    Buffer.BlockCopy(msg, 5, data, 0, msg.Length - 10);
                    message = BSON.Deserialize <Message>(data);

                    if (message is RecordMessage)
                    {
                        RecordMessage rc = message as RecordMessage;
                        //Console.WriteLine("Received: " + rc.htmlRecord.Id);
                        //Thread.Sleep(1000);
                    }
                }
                else
                {
                    message = new DestroyedBuffer();
                }
            }
            catch (Exception ex)
            {
                message = new DestroyedBuffer();
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public void Send(Message message)
        {
            if (message is RecordMessage)
            {
                RecordMessage rm = message as RecordMessage;
                StopTrackingJob(rm.htmlRecord.recordid);
            }

            byte[] bson = BSON.Serialize <Message>(message);
            Send(bson);
        }
Ejemplo n.º 3
0
        public void OnServerConnection(object sender, EventArgs args)
        {
            Message readyMessage = new ReadyMessage(ObjectId.Empty);

            Send(BSON.Serialize <Message>(readyMessage));
        }