Jamoma API  0.6.0.a19
TTWebSend.cpp
1 /*
2  * @file TTWebSend.cpp
3  * @group network library
4  * @brief Jamoma WebSocket Sender
5  * @see TTWebSocket, TTWebReceive
6  *
7  * @copyright © 2013, Laurent Garnier
8  * License: This code is licensed under the terms of the "New BSD License"
9  * http://creativecommons.org/licenses/BSD/
10  */
11 
12 #include "TTWebSend.h"
13 
14 #define thisTTClass TTWebSend
15 #define thisTTClassName "web.send"
16 #define thisTTClassTags "network, send"
17 
18 
20 mSocket(NULL)
21 {
23  connect();
24 }
25 
26 TTWebSend::~TTWebSend()
27 {
28  delete mSocket;
29 }
30 
31 void TTWebSend::connect()
32 {
33  delete mSocket;
34  mSocket = new TTWebSocket();
35 }
36 
37 TTErr TTWebSend::send(const TTValue& value, TTValue& unusedOutput)
38 {
39  TTSymbol message;
40 // TTValuePtr arguments;
41 
42  if (mSocket) {
43  // set all application parameters using a TTHash
44  if (value.size()) {
45  if (value[0].type() == kTypeSymbol) {
46  message = value[0];
47  return mSocket->SendMessage(message);
48  }
49  }
50  }
51 
52  return kTTErrGeneric;
53 }
Create a websocket server.
Definition: TTWebSocket.h:47
size_type size() const noexcept
Return the number of elements.
Symbol type.
Definition: TTBase.h:282
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:27
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
Definition: TTBase.h:344
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TT_OBJECT_CONSTRUCTOR
Constructor macro.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTErr SendMessage(TTSymbol &message)
Send message.