Source: RemoteMessage.js

/**
 * RemoteMessage is a class that can be used to distingush
 * whether an anonymous object is actually a message from a remote System.
 */
class RemoteMessage {

    constructor() {

    }

    /**
     * is this object a RemoteMessage?
     * @param {object} o
     */
    static is(o) {

        //example
        //{
        // sender:
        //}

        if (typeof o === 'object')
            if (typeof o.sender === 'string')
                if (typeof o.concern === 'string')
                    return true;

    }

    /**
     * asString generates a string verison of a RemoteMessage
     * @param {string} remotePath
     * @param {object} message
     * @param {Reference} sender
     */
    asString(remotePath, message, sender) {

        return JSON.stringify({
            type: 'message',
            from: sender.path(),
            to: remotePath,
            body: message
        });

    }

}
export default RemoteMessage