Exemplo n.º 1
0
        private void login(ConnectType type)
        {
            if (socket != null && socket.IsAlive)
            {
                return;
            }
            dynamic d = JsonConvert.DeserializeObject(RestApiClient.GETNOAUTH("gateway").Content);

            gateway          = Convert.ToString(d.url);
            ConnectionStatus = Connection.LOGGING_IN;
            socket           = new WebSocket($"{gateway}/?v={api_version}&encoding={encoding}&client_id=430746509714259989");
            CarrotcordLogger.log(CarrotcordLogger.LogSource.WEBSOCKET, $"[CONNECTING] {gateway}, version: {api_version}, encoding: {encoding}");
            socket.ConnectAsync();
            if (type == ConnectType.NORMAL)
            {
                socket.OnOpen += Socket_OnOpenNormal;
            }
            else if (type == ConnectType.RESUME)
            {
                ConnectionStatus   = Connection.RESUMING;
                retryTimer.Enabled = false;
                socket.OnOpen     += Socket_OnOpenResume;
            }
            socket.OnClose   += Socket_OnClose;
            socket.OnMessage += Socket_OnMessage;
        }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (tag_ != null)
            {
                hash ^= Tag.GetHashCode();
            }
            if (info_ != null)
            {
                hash ^= Info.GetHashCode();
            }
            if (ConnectType != 0)
            {
                hash ^= ConnectType.GetHashCode();
            }
            if (ConnectType1 != 0)
            {
                hash ^= ConnectType1.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 接続するメソッド
 /// </summary>
 public void Connect(ConnectType connectType)
 {
     displayLoadingView();
     nowConnectType = connectType;
     PhotonNetwork.ConnectUsingSettings("1.0.0");
     PhotonNetwork.playerName = PlayerDataManager.Instance.UserName;
 }
Exemplo n.º 4
0
        public static NetElementLinkBase CreateLink(ConnectType ct)
        {
            NetElementLinkBase link = null;

            switch (ct)
            {
            case ConnectType.ATP_DIRECT_LINK:
                link = new AtpDirectLink();
                break;

            case ConnectType.ATP_REMOTE_LOG:
                link = new AtpRemoteLogLink();
                break;

            case ConnectType.ATP_REMOTE_MSG:
                link = new AtpRemoteMsgLink();
                break;

            case ConnectType.OSP:
                break;

            case ConnectType.LMT:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(ct), ct, null);
            }

            return(link);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 指定IDのオブジェクトを取得を行います。<br/>
        /// 通信結果を受け取るために必ずコールバックを設定を行います。
        /// </summary>
        /// <param name="objectId">  オブジェクトID</param>
        /// <param name="callback">  コールバック</param>
        public void GetAsync(string objectId, NCMBGetCallback <T> callback)
        {
            if (callback == null)
            {
                throw new ArgumentException("It is necessary to always set a callback.");
            }

            new AsyncDelegate(delegate {
                string url = _getSearchUrl(this._className);                 //クラス毎のURL作成
                //オブジェクト取得API
                url += "/" + objectId;
                ConnectType type = ConnectType.GET;                //メソッドタイプの設定
                //通信処理
                NCMBConnection con = new NCMBConnection(url, type, null, NCMBUser._getCurrentSessionToken());
                con.Connect(delegate(int statusCode, string responseData, NCMBException error) {
                    Dictionary <string, object> resultObj;
                    NCMBObject objectData = null;
                    try {
                        if (error == null)
                        {
                            resultObj  = MiniJSON.Json.Deserialize(responseData) as Dictionary <string, object>;
                            objectData = _convertGetResponse(resultObj);
                        }
                    } catch (Exception e) {
                        error = new NCMBException(e);
                    }
                    //引数はリスト(中身NCMBObject)とエラーをユーザーに返す
                    Platform.RunOnMainThread(delegate {
                        callback((T)objectData, error);
                    });
                    return;
                });
            }).BeginInvoke((IAsyncResult r) => {
            }, null);
        }
Exemplo n.º 6
0
 public static void ExecuteCommand(string sql, ConnectType ConnectType)
 {
     lock (LockO) {
         DBHelper.SetConnectType(ConnectType);
         DBHelper.ExecuteCommand(sql);
     }
 }
Exemplo n.º 7
0
 public Device(ConnectType _type)
 {
     ConnectType = _type;
     IsEnable    = false;
     Time        = 12;
     Speed       = 0;
 }
Exemplo n.º 8
0
        public int         maxCOM;         //最大端口频道数

        ////预置方法定义(提供常用的连接方式,简化参数的设置)
        public void setA2defaultTCP()     //A2雷达TCP连接
        {
            this.connectType    = ConnectType.DRIVER_TYPE_TCP;
            this.serialPort     = "192.168.0.7";
            this.serialBaudrate = 20108;
            this.maxCOM         = 16;
        }
Exemplo n.º 9
0
 public Req(ConnectType connectType, int port, string ip = "")
     : base(SocketType.REQ, connectType, port, ip)
 {
     m_Timer          = new System.Timers.Timer(100);
     m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
     m_Timer.Start();
 }
Exemplo n.º 10
0
        private void connectReader(ConnectType connectType, string addr)
        {
            if (reader != null)
            {                                      //연결해지 처리를 합니다.
                if (reader.IsHandling)             //연결되어 있는 지를 확인하고
                {
                    reader.Close(CloseType.Close); //연결을 해지합니다.
                    return;
                }
            }

            //리더를 생성하고 초기화 합니다.
            //리더에서 발생되는 이벤트을 처리하기 위한 핸들러를 추가해 줍니다.
            reader              = new Reader();
            reader.ReaderEvent += new ReaderEventHandler(OnReaderEvent);
            reader.ModelType    = ModelType;
            reader.ConnectType  = connectType;
            reader.TagType      = TagType;

            if (connectType == ConnectType.Tcp)
            {
                reader.Open(addr, 5578);
            }
            else
            {
                reader.Open(addr, 115200);
            }
        }
Exemplo n.º 11
0
 public NetworkEventArgs(ConnectType connectType, string url, string query)
 {
     Type  = connectType;
     Url   = url;
     Query = query;
     Data  = new Dictionary <string, object>();
 }
Exemplo n.º 12
0
        internal static void _logOut(NCMBCallback callback)
        {
            string      url     = _getLogOutUrl();    //URL作成
            ConnectType type    = ConnectType.GET;
            string      content = null;

            //ログを確認(通信前)
            NCMBDebug.Log("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
            //通信処理
            NCMBConnection con = new NCMBConnection(url, type, content, NCMBUser._getCurrentSessionToken());

            con.Connect(delegate(int statusCode, string responseData, NCMBException error) {
                try {
                    NCMBDebug.Log("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    if (error != null)
                    {
                        NCMBDebug.Log("[DEBUG AFTER CONNECT] Error: " + error.ErrorMessage);
                    }
                    else
                    {
                        _logOutEvent();
                    }
                } catch (Exception e) {
                    error = new NCMBException(e);
                }
                if (callback != null)
                {
                    Platform.RunOnMainThread(delegate {
                        callback(error);
                    });
                }
                return;
            });
        }
Exemplo n.º 13
0
        public ConnectInfoType(ConnectType ConnectType, string IpAddressOrComPortName, int IpPortOrComPortBaudRate)
        {
            this.ConnectType = ConnectType;

            switch (ConnectType)
            {
            case ConnectType.DIRECT:

                this.ComPortInfo = new ComPortInfo(IpAddressOrComPortName, IpPortOrComPortBaudRate);
                this.NetWorkInfo = new NetWorkInfo();
                this.TimeInfo    = new TimeInfo();

                break;

            case ConnectType.TCPIP:

                this.ComPortInfo = new ComPortInfo();
                this.NetWorkInfo = new NetWorkInfo(IpAddressOrComPortName, IpPortOrComPortBaudRate);
                this.TimeInfo    = new TimeInfo();

                break;

            default:

                this.ComPortInfo = new ComPortInfo();
                this.NetWorkInfo = new NetWorkInfo();
                this.TimeInfo    = new TimeInfo();

                break;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 执行命令 :返回执行结果
        /// </summary>
        /// <param name="connectType"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        private static MySqlEntity Get(ConnectType connectType, string sql)
        {
            MySqlEntity mysqlEntity = Connect(connectType); //先获取实体 实体里面包含了链接的对象

            mysqlEntity.CreateCMD(sql);                     //通过实体的创建命令的方法 进行确定命令的sql语句 打开连接
            return(mysqlEntity);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 非同期処理で指定したメールアドレスに対して、<br/>
        /// 会員登録を行うためのメールを送信するよう要求します。<br/>
        /// 通信結果が必要な場合はコールバックを指定するこちらを使用します。
        /// </summary>
        /// <param name="email">メールアドレス</param>
        /// <param name="callback">コールバック</param>
        public static void RequestAuthenticationMailAsync(string email, NCMBCallback callback)
        {
            //URL
            string url = _getmailAddressUserEntryUrl();             //URL

            //コンテント
            NCMBUser user = new NCMBUser();

            user.Email = email;
            string content = user._toJSONObjectForSaving(user.StartSave());

            //Type
            ConnectType type = ConnectType.POST;

            NCMBConnection con = new NCMBConnection(url, type, content, NCMBUser._getCurrentSessionToken());

            NCMBDebug.Log("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
            con.Connect(delegate(int statusCode, string responseData, NCMBException error) {
                NCMBDebug.Log("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                if (callback != null)
                {
                    callback(error);
                }
                return;
            });
        }
Exemplo n.º 16
0
 public void setG4defaultSerial()  //G4雷达端口连接
 {
     this.connectType    = ConnectType.DRIVER_TYPE_SERIALPORT;
     this.serialPort     = "COM3";
     this.serialBaudrate = 230400;
     this.maxCOM         = 16;
 }
Exemplo n.º 17
0
        private static void _ncmbLogIn(string name, string password, string email, NCMBCallback callback)
        {
            string      url  = _getLogInUrl();
            ConnectType type = ConnectType.GET;

            Dictionary <string, object> paramDic = new Dictionary <string, object>();

            paramDic["password"] = password;

            //nameがあればLogInAsync経由 無ければLogInWithMailAddressAsync経由、どちらも無ければエラー
            if (name != null)
            {
                paramDic["userName"] = name;
            }
            else if (email != null)
            {
                paramDic["mailAddress"] = email;
            }
            else
            {
                throw new NCMBException(new ArgumentException("UserName or Email can not be null."));
            }

            url = _makeParamUrl(url + "?", paramDic);

            //ログを確認(通信前)
            NCMBDebug.Log("【url】:" + url + Environment.NewLine + "【type】:" + type);
            //通信処理
            NCMBConnection con = new NCMBConnection(url, type, null, null);

            con.Connect(delegate(int statusCode, string responseData, NCMBException error)
            {
                try
                {
                    NCMBDebug.Log("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    if (error != null)
                    {
                        NCMBDebug.Log("[DEBUG AFTER CONNECT] Error: " + error.ErrorMessage);
                    }
                    else
                    {
                        Dictionary <string, object> responseDic = MiniJSON.Json.Deserialize(responseData) as Dictionary <string, object>;
                        //save Current user
                        NCMBUser logInUser = new NCMBUser();
                        logInUser._handleFetchResult(true, responseDic);
                        _saveCurrentUser(logInUser);
                    }
                }
                catch (Exception e)
                {
                    error = new NCMBException(e);
                }
                if (callback != null)
                {
                    callback(error);
                }
                return;
            });
        }
Exemplo n.º 18
0
        /// <summary>
        /// 根据XML加载范围查找项
        /// </summary>
        /// <param name="xml">XML</param>
        /// <param name="lstScope">范围集合</param>
        internal static void LoadScopeItems(Stream stm, ScopeList lstScope)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(stm);

            XmlNodeList nodeList = doc.GetElementsByTagName("item");

            foreach (XmlNode node in nodeList)
            {
                string       propertyName    = null;
                ScopeType    stype           = ScopeType.Between;
                ConnectType  ctype           = ConnectType.And;
                object       value1          = null;
                object       value2          = null;
                XmlAttribute attPropertyName = node.Attributes["propertyname"];
                if (attPropertyName != null)
                {
                    propertyName = attPropertyName.InnerText;
                }

                XmlAttribute attScopeType = node.Attributes["scopetype"];
                if (attScopeType != null)
                {
                    stype = (ScopeType)Convert.ToInt32(attScopeType.InnerText);
                }

                XmlAttribute attConnectType = node.Attributes["connecttype"];
                if (attConnectType != null)
                {
                    ctype = (ConnectType)Convert.ToInt32(attConnectType.InnerText);
                }
                foreach (XmlNode itemNode in node.ChildNodes)
                {
                    object       value   = null;
                    Type         objType = null;
                    XmlAttribute attType = itemNode.Attributes["datatype"];
                    if (attType != null)
                    {
                        objType = Type.GetType(attType.InnerText);
                    }
                    else
                    {
                        objType = typeof(string);
                    }
                    value = ListXMLExtends.StringToValue(itemNode.InnerText, objType);
                    if (itemNode.Name == "value1")
                    {
                        value1 = value;
                    }
                    else if (itemNode.Name == "value2")
                    {
                        value2 = value;
                    }
                }
                Scope objScope = new Scope(propertyName, value1, value2, stype, ctype);
                lstScope.Add(objScope);
            }
        }
Exemplo n.º 19
0
 public static object GetScalar(string sql, ConnectType ConnectType)
 {
     lock (LockO)
     {
         DBHelper.SetConnectType(ConnectType);
         return(DBHelper.GetScalar(sql));
     }
 }
Exemplo n.º 20
0
 public static DataSet GetDataSet(string sql, ConnectType ConnectType)
 {
     lock (LockO)
     {
         DBHelper.SetConnectType(ConnectType);
         return(DBHelper.GetDataSet(sql));
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// 条件
 /// </summary>
 /// <param name="propertyName">属性名</param>
 /// <param name="value1">值1</param>
 /// <param name="value2">值2</param>
 /// <param name="scopeType">条件类型</param>
 /// <param name="connectType">连接类型</param>
 public Scope(string propertyName, object value1, object value2, ScopeType scopeType, ConnectType connectType)
 {
     this.propertyName = propertyName;
     this.value1       = value1;
     this.value2       = value2;
     this.scopeType    = scopeType;
     this.connectType  = connectType;
 }
Exemplo n.º 22
0
 public static DataTable GetDataTable(string sql, ConnectType ConnectType)
 {
     lock (LockO)
     {
         New_DbHelper.SetConnectType(ConnectType);
         return(DBHelper.GetDataTable(sql));
     }
 }
Exemplo n.º 23
0
        public ConnectInfoType(ConnectInfoType ConnectInfo)
        {
            this.ConnectType = ConnectInfo.ConnectType;

            this.ComPortInfo = new ComPortInfo(ConnectInfo.ComPortInfo);
            this.NetWorkInfo = new NetWorkInfo(ConnectInfo.NetWorkInfo);
            this.TimeInfo    = new TimeInfo(ConnectInfo.TimeInfo);
        }
Exemplo n.º 24
0
        public ConnectInfoType()
        {
            this.ConnectType = ConnectType.DISABLED;

            this.ComPortInfo = new ComPortInfo();
            this.NetWorkInfo = new NetWorkInfo();
            this.TimeInfo    = new TimeInfo();
        }
Exemplo n.º 25
0
 public void Init(string ip, int port, ConnectType type)
 {
     _ip   = ip;
     _port = port;
     _currentConnectType = type;
     StartCoroutine(Connect());
     StartCoroutine(OnSendMessage());
 }
Exemplo n.º 26
0
 public void Init(Connection connection)
 {
     Type       = connection.connectType;
     Source     = connection.sourceNode.ID;
     SourcePort = connection.sourcePort.name;
     Target     = connection.targetNode.ID;
     TargetPort = connection.targetPort.name;
 }
Exemplo n.º 27
0
        private static void _ncmbLogIn(string name, string password, string email, NCMBCallback callback)
        {
            string      url  = _getLogInUrl();       //URL作成
            ConnectType type = ConnectType.GET;
            //set username, password
            NCMBUser logInUser = new NCMBUser();

            logInUser.Password = password;

            //nameがあればLogInAsync経由 無ければLogInWithMailAddressAsync経由、どちらも無ければエラー
            if (name != null)
            {
                logInUser.UserName = name;
            }
            else if (email != null)
            {
                logInUser.Email = email;
            }
            else
            {
                throw new NCMBException(new ArgumentException("UserName or Email can not be null."));
            }

            string content = logInUser._toJSONObjectForSaving(logInUser.StartSave());
            Dictionary <string, object> paramDic = (Dictionary <string, object>)MiniJSON.Json.Deserialize(content);

            url = _makeParamUrl(url + "?", paramDic);
            //ログを確認(通信前)
            NCMBDebug.Log("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
            //通信処理
            NCMBConnection con = new NCMBConnection(url, type, content, NCMBUser._getCurrentSessionToken());

            con.Connect(delegate(int statusCode, string responseData, NCMBException error) {
                try {
                    NCMBDebug.Log("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    if (error != null)
                    {
                        NCMBDebug.Log("[DEBUG AFTER CONNECT] Error: " + error.ErrorMessage);
                    }
                    else
                    {
                        Dictionary <string, object> responseDic = MiniJSON.Json.Deserialize(responseData) as Dictionary <string, object>;
                        logInUser._handleFetchResult(true, responseDic);
                        //save Current user
                        _saveCurrentUser(logInUser);
                    }
                } catch (Exception e) {
                    error = new NCMBException(e);
                }
                if (callback != null)
                {
                    Platform.RunOnMainThread(delegate {
                        callback(error);
                    });
                }
                return;
            });
        }
Exemplo n.º 28
0
 public CubeManager(ConnectType type = ConnectType.Auto)
 {
     this.scanner    = new CubeScanner(type);
     this.connecter  = new CubeConnecter(type);
     this.cubes      = new List <Cube>();
     this.handles    = new List <CubeHandle>();
     this.navigators = new List <CubeNavigator>();
     this.cubeTable  = new Dictionary <string, Cube>();
 }
Exemplo n.º 29
0
 //コンストラクタ
 internal NCMBConnection(String url, ConnectType method, string content, string sessionToken)
 {
     this._method         = method;
     this._content        = content;
     this._url            = url;
     this._sessionToken   = sessionToken;
     this._applicationKey = NCMBSettings.ApplicationKey;
     this._clientKey      = NCMBSettings.ClientKey;
 }
Exemplo n.º 30
0
        private string _url = ""; //リクエスト先URL

        #endregion Fields

        #region Constructors

        //コンストラクタ
        internal NCMBConnection(String url, ConnectType method, string content, string sessionToken)
        {
            this._method = method;
            this._content = content;
            this._url = url;
            this._sessionToken = sessionToken;
            this._applicationKey = NCMBSettings.ApplicationKey;
            this._clientKey = NCMBSettings.ClientKey;
        }
Exemplo n.º 31
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="connectString">连接字符串</param>
 /// <param name="type">数据库类型</param>
 public DBAccessor(string connectString, ConnectType type)
 {
     if (connectString == string.Empty)
     {
         throw new Exception("数据库连接字符串未指定");
     }
     this.connectionString = connectString;
     this.connectType      = type;
 }
        public SqlStorProcExecCode(List<StoreProcedure> storeProcedures, bool? IsSqlConnection, bool? needTransaction, string namespaceName, string className, string functionAuthority, string execSqlClassName)
        {
            if (storeProcedures == null) throw new ArgumentNullException("StoreProcedures");
            this.storeProcedures = storeProcedures;

            if (IsSqlConnection != null)
            {
                if (!(bool)IsSqlConnection)
                    this.connectType = ConnectType.ConnectionString;
            }
            if (needTransaction != null) { this.needTransaction = (bool)needTransaction; }
            if (namespaceName != null && namespaceName.Length > 0) { this.namespaceName = namespaceName; }
            if (className != null && className.Length > 0) { this.className = className; }
            if (functionAuthority != null && functionAuthority.Length > 0) { this.functionAuthority = functionAuthority; }
            if (execSqlClassName != null && execSqlClassName.Length > 0) { this.execSqlClassName = execSqlClassName; }
        }
Exemplo n.º 33
0
 protected PacketMessage ParsePacketMessage(string clientAddress, string paramString, ConnectType connectType)
 {
     ParamGeter paramGeter = new ParamGeter(paramString);
     PacketHead head = new PacketHead(connectType, PacketMsgType.Request);
     head.Address = clientAddress;
     head.MsgId = paramGeter.GetInt("msgid");
     head.Uid = paramGeter.GetInt("uid");
     head.ActionId = paramGeter.GetInt("actionId");
     string[] sidArray = paramGeter.GetString("sid").Split('|');
     if (sidArray.Length > 2)
     {
         head.GameId = sidArray[1].ToInt();
         head.ServerId = sidArray[2].ToInt();
     }
     else
     {
         head.GameId = paramGeter.GetInt("gametype");
         head.ServerId = paramGeter.GetInt("serverid");
     }
     head.EnableGzip = false;
     PacketMessage packet = new PacketMessage();
     packet.Head = head;
     packet.Content = BufferUtils.GetBytes(paramString);
     return packet;
 }
Exemplo n.º 34
0
        private ConnectionBase ConnectionFactory(ConnectType type)
        {
            switch (type)
            {
                case ConnectType.Ethernet:
                    return new NetConnect();
                case ConnectType.USB:

                    return new ComConnect();
                default:
                    throw new Exception("No interface selected");
            }
        }
Exemplo n.º 35
0
 /// <summary>
 ///     Enable mcu connection
 /// </summary>
 /// <param name="to"> Ipadress or portname </param>
 /// <param name="type">Either net or com</param>
 /// <param name="mode"></param>
 public void CreateConnection(string to, ConnectType type, ConnectMode mode)
 {
     if (string.IsNullOrWhiteSpace(to)) return;
     _desiredMode = mode;
     _mcucomm.Fire(Cevts.Connect, Tuple.Create(to, type));
 }