Esempio n. 1
0
        public void InitMessageBuffer(MessageBufferPersistencyType persistency)
        {
            Trace.Call(persistency);

            if (MessageBuffer != null)
            {
                return;
            }

            switch (persistency)
            {
            case MessageBufferPersistencyType.Volatile:
                MessageBuffer = new ListMessageBuffer();
                break;

            case MessageBufferPersistencyType.Persistent:
                try {
                    MessageBuffer = new Db4oMessageBuffer(
                        ProtocolManager.Session.Username,
                        ProtocolManager.Protocol,
                        ProtocolManager.NetworkID,
                        ID
                        );
                } catch (Exception ex) {
#if LOG4NET
                    _Logger.Error(
                        "InitMessageBuffer(): Db4oMessageBuffer() threw " +
                        "exception, falling back to memory backend!", ex
                        );
#endif
                    MessageBuffer = new ListMessageBuffer();
                }
                break;
            }
        }
Esempio n. 2
0
        public void InitMessageBuffer(MessageBufferPersistencyType persistency)
        {
            Trace.Call(persistency);

            if (MessageBuffer != null)
            {
                return;
            }

            switch (persistency)
            {
            case MessageBufferPersistencyType.Volatile:
                MessageBuffer = new ListMessageBuffer();
                break;

            case MessageBufferPersistencyType.Persistent:
                try {
                    var start = DateTime.UtcNow;
                    MessageBuffer = new Db4oMessageBuffer(
                        ProtocolManager.Session.Username,
                        ProtocolManager.Protocol,
                        ProtocolManager.NetworkID,
                        ID
                        );
                    var stop = DateTime.UtcNow;
#if LOG4NET
                    _Logger.DebugFormat(
                        "InitMessageBuffer(): initializing " +
                        "Db4oMessageBuffer({0}, {1}, {2}, {3}) " +
                        "took: {4:0.00} ms",
                        ProtocolManager.Session.Username,
                        ProtocolManager.Protocol,
                        ProtocolManager.NetworkID,
                        ID,
                        (stop - start).TotalMilliseconds
                        );
#endif
                } catch (Exception ex) {
#if LOG4NET
                    _Logger.Error(
                        "InitMessageBuffer(): Db4oMessageBuffer() threw " +
                        "exception, falling back to memory backend!", ex
                        );
#endif
                    MessageBuffer = new ListMessageBuffer();

                    var builder = new MessageBuilder();
                    builder.AppendEventPrefix();
                    builder.AppendErrorText(
                        _("Failed to open chat history for writing. " +
                          "Your chat history will not be preserved. " +
                          "Reason: {0}"),
                        ex.Message
                        );
                    MessageBuffer.Add(builder.ToMessage());
                }
                break;
            }
        }