+/**
+ * @file Messaging module providing capability for files to communicate with each other
+ * @author Jordan Lavatai and Ken Grimes
+ * @version 0.0.1
+ * @license AGPL-3.0
+ * @copyright Strapp.io
+ */
+
+/** Remote Peer States:
+ unintialized
+
+
+/* SPC default object */
+class StrappPeerConnection extends File {
+ GET() {
+ }
+ POST() {
+ }
+ CONNECT() {
+ }
+ OPTIONS() {
+ }
+ DELETE() {
+ }
+
+}
+
+
+strappPeerConnection.defaults = Object.assign({}, File.defaults, {
+ state: '',
+ messageCount: 0,
+ messageHandler: new Map(), /* TODO: seperate handling? */
+ remotePeer: {
+ bestConnectionType: '',
+ state: '',
+ peerID: '' /* clientID of Peer* /
+ }
+}
+
+/* GET - gets the data (queued messages) from a spc */
+/* POST - sends a msg through a spc to the remote peer */
+/* CONNECT - Tries to establish a connection with an spc */
+/* local or remote peer of the spc? */
+ /* Local is part of uri, make it remote*/
+
+/* File System */
+/* Convert entire file system into json objects that can be read into memory */
+
+
+/* Send */
+/* Receive */
+/* Reconnect WebRTC */
+/* Reconnect WS */
+/* Determine remote peers bestConnectionType */
+/* Restablish connection */
+
+
+/** @func Send a message to the remote peer
+ * @desc
+ *
+ * @arg {Object} message - message in LMKID format, except no message ID yet
+ * @this {Object} - Refers to the SPC that is calling send
+ * @return {Object} - Promise for the response from the send message
+ */
+function send(message) {
+ /* Determine if 'this' is a SPC object */
+
+
+ /* 'send data' means to create a strapp protocol message and send it over whichever
+ transmission channel is available */
+ switch (this.state) {
+ case 'unintialized':
+ case 'offline':
+ if (this.establishConnection(clientKey, data)) {
+ send(clientKey, data)
+ }
+ else {
+ storeMessage(this, message)
+ }
+
+ break
+ case 'disconnected':
+ this.reestablishConnection(clientKey, data)
+ /* Store the message */
+ /* Fail if reconnection attempt fails */
+ break
+ case 'polling': {
+ /* does remote peer have the ability to upgrade? */
+ /* If so, attempt to upgrade */
+ /* If upgrade fails, retry the send method else send via polling */
+ break
+ }
+ case 'webSocket': {
+ /* does remote peer have the ability to upgrade? */
+ /* If so, attempt to upgrade */
+ /* If upgrade fails, retry the send method else send via polling */
+ break
+ }
+ case 'webRTC': {
+ /* If remote peer is connected, send data */
+ /* Else Attemp to fix connection, if connection is dead, set this.state and try this again. Will
+ Enter the 'disconnected' state */
+ break
+ }
+
+ }
+}
+
+
+
+/** @func Attempts to connect the local peer to the remote peer
+ * @desc
+ *
+ * @ret {boolean} True if successful, false if not
+ */
+function establishSPC() {
+
+}
+
+/** @func Attempts to reconnect the local peer to the remote peer
+ * @desc This function assumes that the remotePeer property for the SPC object has
+ * been elevated to a status higher than uninitialized.
+ *
+ * @ret {boolean} True if successful, false if not
+ */
+function reestablishSPC() {
+ /* If successful, send all the cached messages that were saved when connection was down */
+}
+
+
+/** @func Stores the message
+ * @desc
+ *
+ */
+function storeMessage() {
+}
+
+/** @func Determines the multimedia signaling protocol for the given session description
+ * @desc Does some basic duck typing to determine the type of Session Description
+ * @arg {Object} Session Description Object
+ * @return {String} Returns 'planB' if Session Description is planB, 'Unified' if
+ * Session Description is Unified
+ */
+function determineSessionDescription(sessionDescription) {
+}
+
+/** @func Converts a planB session description to Unified session description
+ * @arg {Object} Session Description Object
+ * @return {Object} PlanB Session Description
+ */
+function toUnified(sessionDescription) {
+}
+
+/** @func Converts a Unified session description to planB session description
+ * @arg {Object} Session Description Object
+ * @return {Object} PlanB Session Description
+ */
+function toPlanB(sessionDescription) {
+}