Subversion Repositories HomeAutomation

Rev

Rev 1962 | Go to most recent revision | Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1651 runge 1
 
2
Socket_Connections = {};
3
 
4
function Socket_OnNewData(socket_id, data)
5
{
6
    if (Socket_Connections[socket_id])
7
    {
8
        Socket_Connections[socket_id]["ondata"](socket_id, data);
9
    }
10
}
11
 
12
function Socket_OnNewState(socket_id, state)
13
{
14
    if (Socket_Connections[socket_id])
15
    {
16
        Socket_Connections[socket_id]["onstate"](socket_id, state);
17
    }
18
}
19
 
20
function Socket_Connect(address, port, ondata_callback, onstate_callback)
21
{
22
    socket_id = SocketExport_Connect(address, port);
23
 
24
    if (socket_id > 0)
25
    {
26
        Socket_Connections[socket_id] = { "ondata" : ondata_callback, "onstate" : onstate_callback };
27
    }
28
 
29
    return socket_id;
30
}
31
 
32
function Socket_Disconnect(socket_id)
33
{
34
    SocketExport_Disconnect(socket_id);
35
 
36
    delete Socket_Connections[socket_id];
37
}
38
 
39
function Socket_Send(socket_id, data)
40
{
41
    SocketExport_Send(socket_id, data);
42
}