private void joinTestChannel(int interfaceType) { /// <summary> /// 5. Join my channel /// </summary> addLogView(interfaceType, " joinChannel()"); SchordChannel channel = null; SchordManager currentManager = null; currentManager = getSchordManager(interfaceType); switch (interfaceType) { case SchordManager.INTERFACE_TYPE_WIFI: channel = currentManager.joinChannel(CHORD_HELLO_TEST_CHANNEL, mWifi_ChannelListener); break; case SchordManager.INTERFACE_TYPE_WIFI_P2P: channel = currentManager.joinChannel(CHORD_HELLO_TEST_CHANNEL, mWifiDirect_ChannelListener); break; case SchordManager.INTERFACE_TYPE_WIFI_AP: channel = currentManager.joinChannel(CHORD_HELLO_TEST_CHANNEL, mMobileAP_ChannelListener); break; } if (channel == null) { addLogView(interfaceType, " Fail to joinChannel"); } }
private void stopChord(int ifc) { /// <summary> /// 7. Stop Chord. You can call leaveChannel explicitly. /// mSchordManager_1.leaveChannel(CHORD_HELLO_TEST_CHANNEL); /// </summary> SchordManager currentManager = null; currentManager = getSchordManager(ifc); if (currentManager == null) { return; } currentManager.stop(); switch (ifc) { case SchordManager.INTERFACE_TYPE_WIFI: mWifi_startStop_btn.Enabled = false; break; case SchordManager.INTERFACE_TYPE_WIFI_P2P: mWifiDirect_startStop_btn.Enabled = false; break; case SchordManager.INTERFACE_TYPE_WIFI_AP: mMobileAP_startStop_btn.Enabled = false; break; } addLogView(ifc, " stop(" + getInterfaceName(ifc) + ")"); }
private void initChord() { /// <summary> ///************************************************** /// 1. GetInstance /// *************************************************** /// </summary> Schord chord = new Schord(); try { chord.initialize(this); } catch (SsdkUnsupportedException e) { if (e.Type == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) { // Vender is not SAMSUNG return; } } Log.d(TAG, TAGClass + "initChord : VersionName( " + chord.VersionName + " ), VerionCode( " + chord.VersionCode + " )"); mSchordManager_1 = new SchordManager(this); /// <summary> ///************************************************** /// 2. Set some values before start If you want to use secured channel, /// you should enable SecureMode. Please refer /// UseSecureChannelFragment.java mChordManager.enableSecureMode(true); /// Once you will use sendFile or sendMultiFiles, you have to call /// setTempDirectory mChordManager.setTempDirectory(Environment. /// getExternalStorageDirectory().getAbsolutePath() + "/Chord"); /// *************************************************** /// </summary> mSchordManager_1.Looper = MainLooper; /// <summary> /// Optional. If you need listening network changed, you can set callback /// before starting chord. /// </summary> mSchordManager_1.NetworkListener = new NetworkListenerAnonymousInnerClassHelper(this); IList <int?> ifcList = mSchordManager_1.AvailableInterfaceTypes; foreach (int?ifc in ifcList) { refreshInterfaceStatus(ifc.Value, true); } }
private SchordManager getSchordManager(int interfaceType) { int managerIndex = 0; SchordManager manager = null; managerIndex = mInterfaceMap.get(interfaceType); switch (managerIndex) { case 1: manager = mSchordManager_1; break; case 2: manager = mSchordManager_2; break; case 3: manager = mSchordManager_3; break; } return(manager); }
private void startChord(int interfaceType) { /// <summary> /// 3. Start Chord using the first interface in the list of available /// interfaces. /// </summary> addLogView(interfaceType, "\n[A] Start Chord!"); int managerIndex = 0; SchordManager startManager = null; if (mInterfaceMap.get(interfaceType) == 0) { managerIndex = mInterfaceMap.size() + 1; mInterfaceMap.put(interfaceType, managerIndex); } else { managerIndex = mInterfaceMap.get(interfaceType); } switch (managerIndex) { case 1: startManager = mSchordManager_1; break; case 2: mSchordManager_2 = new SchordManager(this); startManager = mSchordManager_2; break; case 3: mSchordManager_3 = new SchordManager(this); startManager = mSchordManager_3; break; } try { Log.d(TAG, TAGClass + "start(" + getInterfaceName(interfaceType) + ") with the SchordManager number : " + managerIndex); startManager.Looper = MainLooper; startManager.SecureModeEnabled = true; switch (interfaceType) { case SchordManager.INTERFACE_TYPE_WIFI: startManager.start(interfaceType, mWifi_ManagerListener); break; case SchordManager.INTERFACE_TYPE_WIFI_P2P: startManager.start(interfaceType, mWifiDirect_ManagerListener); break; case SchordManager.INTERFACE_TYPE_WIFI_AP: startManager.start(interfaceType, mMobileAP_ManagerListener); break; } addLogView(interfaceType, " start(" + getInterfaceName(interfaceType) + ")"); } catch (Exception e) { addLogView(interfaceType, " Fail to start -" + e.Message); mInterfaceMap.delete(interfaceType); } }
private void initChord() { /// <summary> ///************************************************** /// 1. GetInstance /// *************************************************** /// </summary> Schord chord = new Schord(); try { chord.initialize(this); } catch (SsdkUnsupportedException e) { if (e.Type == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) { // Vender is not SAMSUNG return; } } mSchordManager_1 = new SchordManager(this); mSchordManager_1.Looper = MainLooper; /// <summary> ///*************************************************** /// 2. You have to enable SecureMode to use Secured channel. It is false /// as default. If you do not set and try to joinChannel with Secured /// name, it will throw IllegalArgumentException. /// *************************************************** /// </summary> mSchordManager_1.SecureModeEnabled = true; /// <summary> /// Optional. If you need listening network changed, you can set callback /// before starting chord. /// </summary> mSchordManager_1.NetworkListener = new NetworkListenerAnonymousInnerClassHelper(this); IList<int?> ifcList = mSchordManager_1.AvailableInterfaceTypes; foreach (int? ifc in ifcList) { startChord(ifc.Value); refreshInterfaceStatus(ifc.Value, true); } }
private void startChord(int interfaceType) { /// <summary> /// 3. Start Chord using the selected interface in the list of available /// interfaces. You can get a list of available network interface types /// List<Integer> infList = /// mSchordManager_1.getAvailableInterfaceTypes().isEmpty(); /// if(infList.isEmpty()) // there is no active interface! /// </summary> int managerIndex = 0; SchordManager startManager = null; if (mInterfaceMap.get(interfaceType) == 0) { managerIndex = mInterfaceMap.size() + 1; mInterfaceMap.put(interfaceType, managerIndex); } else { managerIndex = mInterfaceMap.get(interfaceType); } switch (managerIndex) { case 1: startManager = mSchordManager_1; break; case 2: mSchordManager_2 = new SchordManager(this); startManager = mSchordManager_2; break; case 3: mSchordManager_3 = new SchordManager(this); startManager = mSchordManager_3; break; } try { Log.d(TAG, TAGClass + "start(" + getInterfaceName(interfaceType) + ") with the SchordManager number : " + managerIndex); startManager.Looper = MainLooper; switch (interfaceType) { case SchordManager.INTERFACE_TYPE_WIFI: startManager.start(interfaceType, mWifi_ManagerListener); mWifi_startStop_btn.Enabled = false; break; case SchordManager.INTERFACE_TYPE_WIFI_P2P: startManager.start(interfaceType, mWifiDirect_ManagerListener); mWifiDirect_startStop_btn.Enabled = false; break; case SchordManager.INTERFACE_TYPE_WIFI_AP: startManager.start(interfaceType, mMobileAP_ManagerListener); mMobileAP_startStop_btn.Enabled = false; break; } addLogView(interfaceType, " start(" + getInterfaceName(interfaceType) + ")"); } catch (Exception e) { addLogView(interfaceType, " Fail to start -" + e.Message); mInterfaceMap.delete(interfaceType); } }
private void initChord() { /// <summary> ///************************************************** /// 1. GetInstance /// *************************************************** /// </summary> Schord chord = new Schord(); try { chord.initialize(this); } catch (SsdkUnsupportedException e) { if (e.Type == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) { // Vender is not SAMSUNG return; } } Log.d(TAG, TAGClass + "initChord : VersionName( " + chord.VersionName + " ), VerionCode( " + chord.VersionCode + " )"); mSchordManager_1 = new SchordManager(this); /// <summary> ///************************************************** /// 2. Set some values before start If you want to use secured channel, /// you should enable SecureMode. Please refer /// UseSecureChannelFragment.java mChordManager.enableSecureMode(true); /// Once you will use sendFile or sendMultiFiles, you have to call /// setTempDirectory mChordManager.setTempDirectory(Environment. /// getExternalStorageDirectory().getAbsolutePath() + "/Chord"); /// *************************************************** /// </summary> mSchordManager_1.Looper = MainLooper; /// <summary> /// Optional. If you need listening network changed, you can set callback /// before starting chord. /// </summary> mSchordManager_1.NetworkListener = new NetworkListenerAnonymousInnerClassHelper(this); IList<int?> ifcList = mSchordManager_1.AvailableInterfaceTypes; foreach (int? ifc in ifcList) { refreshInterfaceStatus(ifc.Value, true); } }