Ejemplo n.º 1
0
        /// <summary>
        /// 初期化
        /// </summary>
        /// <param name="args">コマンドライン</param>
        public void Initialize(string[] args)
        {
            MrsCmdParser parser = new MrsCmdParser('-');

            parser.Parse(args);

            m_connectionType    = (MrsConnectionType)parser.GetNumeric <Int32>("connectionType", (Int32)MrsConnectionType.TCP);
            m_canKeyExchange    = (parser.GetNumeric <Int32>("is_key_exchange", 1) != 0) ? true : false;
            m_canEncryptRecords = (parser.GetNumeric <Int32>("is_encrypt_records", 1) != 0) ? true : false;
            m_nRecordOptions    = (ushort)((m_canEncryptRecords == true) ? MrsRecordOption.ON_CRYPT : MrsRecordOption.NONE);
            m_nWriteDataLen     = parser.GetNumeric <UInt32>("write_data_len", 1024);
            m_nWriteCount       = parser.GetNumeric <UInt32>("write_count", 10);
            m_nConnections      = parser.GetNumeric <UInt32>("connections", 1);
            m_SleepMsec         = parser.GetNumeric <UInt32>("sleep_msec", 1);

            m_server_addr    = parser.GetString("server_addr", "127.0.0.1");
            m_server_port    = parser.GetNumeric <ushort>("server_port", 22222);
            m_timeout_msec   = parser.GetNumeric <UInt32>("timeout_msec", 5000);
            m_canValidRecord = (parser.GetNumeric <Int32>("is_valid_record", 1) != 0) ? true : false;
            m_ConnectionPath = parser.GetString("connection_path", "/");

            mrs.Connect.Request connect_request = new mrs.Connect.Request();
            connect_request.ConnectionType = MrsConnectionType.NONE;
            connect_request.Addr           = m_server_addr;
            connect_request.Port           = m_server_port;
            connect_request.TimeoutMsec    = m_timeout_msec;

            switch (m_connectionType)
            {
            case MrsConnectionType.TCP:
            case MrsConnectionType.UDP:
            case MrsConnectionType.WS:
            case MrsConnectionType.WSS:
            case MrsConnectionType.TCP_SSL:
            case MrsConnectionType.MRU:
            {
                connect_request.ConnectionType = m_connectionType;
                g_Connect.AddRequest(connect_request);
            }
            break;

            default:
            {
                connect_request.ConnectionType = MrsConnectionType.TCP;
                g_Connect.AddRequest(connect_request);

                connect_request.ConnectionType = MrsConnectionType.WSS;
                connect_request.Port          += 2;
                g_Connect.AddRequest(connect_request);

                connect_request.ConnectionType = MrsConnectionType.WS;
                connect_request.Port          -= 1;
                g_Connect.AddRequest(connect_request);
            }
            break;
            }
            g_Connect.SetFallbackConnectCallback(m_FallbackConnectCallback);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// コネクションタイプを表す文字列を返す
 /// </summary>
 private static string ConnectionTypeToString(MrsConnection connection)
 {
     MrsConnectionType type = mrs_connection_get_type( connection );
     switch ( type )
     {
     case MrsConnectionType.NONE:{ return "NONE"; }
     case MrsConnectionType.TCP:{ return "TCP"; }
     case MrsConnectionType.UDP:{ return "UDP"; }
     }
     return "INVALID";
 }
Ejemplo n.º 3
0
    private static String connection_type_to_string(MrsConnection connection)
    {
        MrsConnectionType type = mrs_connection_get_type(connection);

        switch (type)
        {
        case MrsConnectionType.NONE: { return("NONE"); }

        case MrsConnectionType.TCP: { return("TCP"); }

        case MrsConnectionType.UDP: { return("UDP"); }

        case MrsConnectionType.WS: { return("WS"); }

        case MrsConnectionType.WSS: { return("WSS"); }

        case MrsConnectionType.TCP_SSL: { return("TCP_SSL"); }

        case MrsConnectionType.MRU: { return("MRU"); }
        }
        return("INVALID");
    }