@@ -9,7 +9,7 @@ namespace signalr
9
9
enum MessageType
10
10
{
11
11
Negotiation = 0 ,
12
- Invocation,
12
+ Invocation = 1 ,
13
13
StreamInvocation,
14
14
StreamItem,
15
15
Completion,
@@ -28,22 +28,29 @@ namespace signalr
28
28
switch (messageType.as_integer ())
29
29
{
30
30
case MessageType::Negotiation:
31
+ // unused...
31
32
break ;
32
33
case MessageType::Invocation:
33
34
{
34
35
auto method = value[L" target" ];
35
36
auto args = value[L" arguments" ];
37
+ _ASSERT (args.is_array ());
36
38
break ;
37
39
}
38
40
case MessageType::StreamInvocation:
39
- break ;
41
+ // Sent to server only, should not be received by client
42
+ throw std::runtime_error (" Received unexcepted message type 'StreamInvocation'." );
40
43
case MessageType::StreamItem:
44
+ // TODO
41
45
break ;
42
46
case MessageType::Completion:
47
+ // TODO
43
48
break ;
44
49
case MessageType::CancelInvocation:
45
- break ;
50
+ // Sent to server only, should not be received by client
51
+ throw std::runtime_error (" Received unexcepted message type 'CancelInvocation'." );
46
52
case MessageType::Ping:
53
+ // TODO
47
54
break ;
48
55
}
49
56
});
@@ -63,16 +70,20 @@ namespace signalr
63
70
return mTransport ->Stop ();
64
71
}
65
72
66
- pplx::task<void > HubConnection::SendCore (const utility::string_t & message )
73
+ pplx::task<void > HubConnection::Send (const utility::string_t & target, const utility:: string_t & arguments )
67
74
{
68
- // _ASSERT(message.is_array());
69
- // web::json::value invocation;
70
- // invocation[L"type"] = web::json::value::value(1);
71
- // invocation[L"target"] = web::json::value::string(target);
72
- // invocation[L"arguments"] = message;
75
+ auto args = web::json::value::parse (arguments);
76
+ _ASSERT (args.is_array ());
73
77
74
- // auto request = web::websockets::client::websocket_outgoing_message();
75
- // request.set_utf8_message(utility::conversions::to_utf8string(invocation.serialize()) + "\x1e");
78
+ web::json::value invocation;
79
+ invocation[L" type" ] = web::json::value::value (MessageType::Invocation);
80
+ invocation[L" target" ] = web::json::value::string (target);
81
+ invocation[L" arguments" ] = args;
82
+ return SendCore (invocation.serialize () + L" \x1e " );
83
+ }
84
+
85
+ pplx::task<void > HubConnection::SendCore (const utility::string_t & message)
86
+ {
76
87
return mTransport ->Send (message);
77
88
}
78
89
0 commit comments