Release Notes: (1.0.0)
  • Inital version.

Integration Guide - Samsung Chord Plugin

Platforms: Android only
Plugin version: 1.0.0
Chord SDK version: 1.0.0

Generally you don't have to dive into the documentation from Samsung, simply follow a few steps below to get the plugin integrated in your App in minutes:

[1] Import the SamsungChordAndroid.unitypackage file to your project;

[2] Click on the menu item of Unity top menu bar: NeatPlug -> SamsungChord -> Patch Android Configuration. This is for generating a valid AndroidManifest.xml or patching the existing file with SamsungChord support.

[3] Find SamsungChordAgent Prefab and SamsungChordListener Prefab in Assets/Plugins/NeatPlug/Multiplayer/SamsungChord/Prefabs/, open the first scene of your game, drag & drop those two prefabs into the scene.

[4] OK, your integration is done here. Now it is the time to use the Chord! Let's take a look at the functions exposed in the plugin:

  Call the following functions to have Chord work for you:

   · SamsungChord.Instance().Start(...) - Start Chord, required before you make any other Chord calls.

   · SamsungChord.Instance().Stop() - Stop Chord.

   · SamsungChord.Instance().JoinChannel(...) - Join a channel. (Channel should be unique cross applications)

   · SamsungChord.Instance().LeaveChannel(...) - Leave the joined channel.

   · SamsungChord.Instance().SendMessage(...) - Send a message to all nodes or specified single node.

   · SamsungChord.Instance().SendData(...) - Send data to all nodes or specified single node.

   · SamsungChord.Instance().SendFile(...) - Send a file to a node.

  More details about the functions that SamsungChord provides, may be helpful for you to understand the usage.
Show All   
public void Start(ChordNetworkInterfaceType interfaceType)
/**
 * Start up the Chord.
 * 
 * You should call this function before you make any Chord calls.
 * 
 * You can get the supported interface type from an automatically 
 * triggered event - SamsungChordListener::OnInterfacesDetected()
 * 
 * @param interfaceType
 *           ChordNetworkInterfaceType - The network interface that you 
 *                                       want to start Chord with.
 */
public void Start(ChordNetworkInterfaceType interfaceType)
public void Stop()
/**
 * Stop the Chord. 
 */
public void Stop()
public List<string> GetChannels()
/**
 * Get the available channels.
 */
public List<string> GetChannels()
public List<string> GetNodes(string channel = null)
/**
 * Get the nodes in a channel.
 * 
 * @param channel
 *           string - The channel within which the nodes will be returned.
 *                    Leave it null for Public Channel.
 */
public List<string> GetNodes(string channel = null)
public void JoinChannel(string channel)
/**
 * Join a channel.
 * 
 * Supply the channel name which you would like to join, leave the channel null if you
 * want to join a Public Channel.
 * 
 * @param channel
 *            string - The channel to be joined. You need to make sure the channel name
 *                     is unique cross applications. The best practice is you add your 
 *                     package name as a prefix. For instance: "com.your.package.SomeChannel".
 */
public void JoinChannel(string channel)
public void LeaveChannel()
/**
 * Leave the joined channel.	
 */
public void LeaveChannel()
public void SendMessageToAll(string channel, string message)
/**
 * Send a message to all nodes in a channel. 	
 * 
 * @param channel
 *          string - The channel. (null for Public Channel)
 * 
 * @param message
 *          string - The message to be sent.
 */
public void SendMessageToAll(string channel, string message)
public void SendMessage(string channel, string node, string message)
/**
 * Send a message to a specified node in a channel. 	
 * 
 * @param channel
 *          string - The channel. (null for Public Channel)
 * 
 * @param node
 *          string - The recipient node.
 * 
 * @param message
 *          string - The message to be sent.
 */
public void SendMessage(string channel, string node, string message)
public void SendDataToAll(string channel, byte[] data)
/**
 * Send data to all nodes in a channel. 	
 * 
 * @param channel
 *          string - The channel. (null for Public Channel)
 * 
 * @param data
 *          byte[] - The data to be sent.
 */
public void SendDataToAll(string channel, byte[] data)
public void SendData(string channel, string node, byte[] data)
/**
 * Send data to a specified node in a channel. 	
 * 
 * @param channel
 *          string - The channel. (null for Public Channel)
 * 
 * @param node
 *          string - The recipient node.
 * 
 * @param data
 *          byte[] - The data to be sent.
 */
public void SendData(string channel, string node, byte[] data)
public void SendFile(string channel, string node, string filePath)
/**
 * Send a file to specified node in a channel. 	
 * 
 * @param channel
 * 			string - The channel. (null for Public Channel)
 * 
 * @param node
 *          string - The recipient node.
 * 
 * @param filePath
 *          string - The file to be sent.
 */
public void SendFile(string channel, string node, string filePath)

[5] To receive the messages or data sent from other nodes, you need to handle events:

  Follow the instructions to handle Samsung Chord events:

  · Select the dropped SamsungChordListener gameObject, locate the SamsungChordListener.cs script, open it and make some modifications.

  These callbacks are exposed in the script, you can supply your own implementations in them.
Show All   
void OnInterfacesDetected(List<ChordNetworkInterfaceType> availableInterfaces) { ... }
/**
 * Fired when the available network interfaces are detected.
 *
 * The interfaces will be needed when you call SamsungChord.Instance().Start().
 * 
 * @param availableInterfaces
 *            List<ChordNetworkInterfaceType> - A list of supported network interfaces.
 */
void OnInterfacesDetected(List<ChordNetworkInterfaceType> availableInterfaces)
{
    /// Your code here...   
}
void OnChordStarted() { ... }
/**
 * Fired when Chord is successfully started.	
 */
void OnChordStarted()
{
    /// Your code here...   
}
void OnFailedToStartChord(string err) { ... }
/**
 * Fired when failed to start Chord.
 * 
 * @param err
 *         string - The error message.
 */
void OnFailedToStartChord(string err)
{
    /// Your code here...   
}
void OnMessageReceived(string node, string channel, string message) { ... }
/**
 * Fired when a message is received.
 * 
 * If the channel is null, means the message is from the Public Channel.
 * 
 * @param node
 *          string - The node that sent the message.	
 * 
 * @param channel
 *          string - The channel where the message is from.
 * 
 * @param message
 *          string - The message.
 */
void OnMessageReceived(string node, string channel, string message)
{
    /// Your code here...   
}
void OnDataReceived(string node, string channel, byte[] data) { ... }
/**
 * Fired when a block of data is received.
 * 
 * If the channel is null, means the data is from the Public Channel.
 * 
 * @param node
 *          string - The node that sent the data.	
 * 
 * @param channel
 *          string - The channel where the data is from.
 * 
 * @param data
 *          byte[] - The data.
 */
void OnDataReceived(string node, string channel, byte[] data)
{
    /// Your code here...   
}
void OnFileWillReceive(string node, string channel, string fileName, string exchangeId) { ... }
/**
 * Fired when a file will be received.
 * 
 * If the channel is null, means the file is from the Public Channel.
 * 
 * @param node
 *          string - The node.	
 * 
 * @param channel
 *          string - The channel where the file is sent.
 * 
 * @param fileName
 *          string - The file name.
 * 
 * @param exchangeId
 *          string - The unique ID for identifying the file transimission.
 */	
void OnFileWillReceive(string node, string channel, string fileName, string exchangeId)
{
    /// Your code here...   
}
void OnFileTransmissionProgressChanged(ChordFileTransmissionDirection direction, ... ) { ... }
/**
 * Fired when a file transmission progress is changed.
 * 
 * If the channel is null, means the file is from the Public Channel.
 * 
 * @param direction
 *          ChordFileTransmissionDirection - Tells if the file transimission 
 *                                           on the device is SEND or RECEIVE.
 * 
 * @param node
 *          string - The node.	
 * 
 * @param channel
 *          string - The channel where the file is sent.
 * 
 * @param progress
 *          int - The progress of file transimission.
 * 
 * @param exchangeId
 *          string - The unique ID for identifying the file transimission.
 */
void OnFileTransmissionProgressChanged(ChordFileTransmissionDirection direction, string node, 
                                         string channel, int progress, string exchangeId)
{
    /// Your code here...   
}
void OnFileTransmissionCompleted(ChordFileTransmissionDirection direction, ... ) { ... }
/**
 * Fired when a file transmission is successfully completed.
 * 
 * If the channel is null, means the file is from the Public Channel.
 * 
 * @param direction
 *          ChordFileTransmissionDirection - Tells if the file transimission 
 *                                           on the device is SEND or RECEIVE.
 * 
 * @param node
 *          string - The node.	
 * 
 * @param channel
 *          string - The channel where the file is sent.
 * 
 * @param fileName
 *          string - The file's name.
 * 
 * @param exchangeId
 *          string - The unique ID for identifying the file transimission.
 */	
void OnFileTransmissionCompleted(ChordFileTransmissionDirection direction, string node, 
                                 string channel, string fileName, string exchangeId)
{
    /// Your code here...   
}
void OnFileTransmissionFailed(string node, string channel, string fileName, ... ) { ... }
/**
 * Fired when a file transmission failed.
 * 
 * If the channel is null, means the file is from the Public Channel.
 * 	
 * @param node
 *          string - The node.	
 * 
 * @param channel
 *          string - The channel where the file is sent.
 * 
 * @param fileName
 *          string - The file's name.
 * 
 * @param exchangeId
 *          string - The unique ID for identifying the file transimission.
 * 
 * @param error
 *          string - The error message.
 */
void OnFileTransmissionFailed(string node, string channel, string fileName, 
                              string exchangeId, string exchangeId error)
{
    /// Your code here...   
}
void OnNodeJoined(string node, string channel) { ... }
/**
 * Fired when a node joined a channel.
 * 
 * If the channel is null, means the user joined the Public Channel.
 * 	
 * @param node
 *          string - The node.	
 * 
 * @param channel
 *          string - The channel.
 */
void OnNodeJoined(string node, string channel)
{
    /// Your code here...   
}
void OnNodeLeft(string node, string channel) { ... }
/**
 * Fired when a node left a channel.
 * 
 * If the channel is null, means the user left the Public Channel.
 * 	
 * @param node
 *          string - The node.	
 * 
 * @param channel
 *          string - The channel.
 */
void OnNodeLeft(string node, string channel)
{
    /// Your code here...   
}
void OnNodeInfoUpdated(string node, string ipAddress) { ... }
/**
 * Fired when a node's information is updated.
 * 	
 * @param node
 *          string - The node.	
 * 
 * @param ipAddress
 *          string - The ip address of the node.
 */
void OnNodeInfoUpdated(string node, string ipAddress)
{
    /// Your code here...   
}
void OnNetworkDisconnected() { ... }
/**
 * Fired when the network is disconnected.
 */
void OnNetworkDisconnected()
{
    /// Your code here...   
}
void OnNetworkConnectivityChanged() { ... }
/**
 * Fired when the network connectivity is changed.
 */
void OnNetworkConnectivityChanged()
{
    /// Your code here...   
}

[6] Test your Chord functionality. It would be helpful for you to address issues if you take a look at the logcat output to find the debug / error / warning messages.

[EOF] If you encounter any problems while integrating the plugin, please do not hesitate to shoot us an email at support@neatplug.com, we will be helping you as soon as possible.Thanks for choosing NeatPlug solutions!