static public int StopRecording_s(IntPtr l)
 {
     try {
         MobileDevicesInterface.StopRecording();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int FinishBroadcast_s(IntPtr l)
 {
     try {
         MobileDevicesInterface.FinishBroadcast();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int OpenSystemWirelessSettings_s(IntPtr l)
 {
     try {
         MobileDevicesInterface.OpenSystemWirelessSettings();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int AvailableDiskSize_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.AvailableDiskSize();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetMacAddress_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.GetMacAddress();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int isPlayerPaused_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.isPlayerPaused();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int HasSupportBroadcast_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.HasSupportBroadcast();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int hasSupportReplay_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.hasSupportReplay();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int IsAndroidDevice_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.IsAndroidDevice();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetNetConnectivityType_s(IntPtr l)
 {
     try {
         var ret = MobileDevicesInterface.GetNetConnectivityType();
         pushValue(l, true);
         pushEnum(l, (int)ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         MobileDevicesInterface o;
         o = new MobileDevicesInterface();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int StartMicrophone_s(IntPtr l)
 {
     try {
         System.Boolean a1;
         checkType(l, 1, out a1);
         MobileDevicesInterface.StartMicrophone(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetIPv6_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         System.String a2;
         checkType(l, 2, out a2);
         var ret = MobileDevicesInterface.GetIPv6(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int ConvertIPAddress_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         System.String a2;
         checkType(l, 2, out a2);
         System.String a3;
         System.Net.Sockets.AddressFamily a4;
         MobileDevicesInterface.ConvertIPAddress(a1, a2, out a3, out a4);
         pushValue(l, true);
         pushValue(l, a3);
         pushValue(l, a4);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #15
0
    /// <summary>
    /// connect to server
    /// </summary>
    /// <param name="szIp">ip adress of server</param>
    /// <param name="port">port number of server</param>
    /// <returns>true if connected to server, otherwise false</returns>
    public bool Connect(string szIp, int port /*, System.Action<int> fn = null, bool bAutoRetry = true, System.Action<int> fnDisconnect = null*/)
    {
        bool          bSuccess         = false;
        string        newServerIp      = "";
        AddressFamily newAddressFamily = AddressFamily.InterNetwork;

        //convert ip address
        MobileDevicesInterface.ConvertIPAddress(szIp, port.ToString(), out newServerIp, out newAddressFamily);
        if (!string.IsNullOrEmpty(newServerIp))
        {
            szIp = newServerIp;
        }
        m_socket = new Socket(newAddressFamily, SocketType.Stream, ProtocolType.Tcp);
        //Debug.Log("Converted Socket AddressFamily :" + newAddressFamily.ToString() + "ServerIp:" + szIp + " port=" + port);

        try
        {
            m_socket.BeginConnect(szIp, port, OnConnected, null);
            m_ConnectStartTime = Time.realtimeSinceStartup;
            m_socketState      = ESocketState.ESS_Connectting;
            bSuccess           = true;
        }
        catch (System.Exception e)
        {
            string tip = string.Format("Connect {0}:{1} Error, {2}", szIp, port.ToString(), e.ToString());
            m_socketState = ESocketState.ESS_ConnecttingFailed;

            FSocketStateChanged state = new FSocketStateChanged(m_socketState, tip);
            if (null != onSocketStateChanged)
            {
                onSocketStateChanged.Invoke(state);
            }
            bSuccess = false;
        }

        return(bSuccess);
    }