[101] | 1 | // ------------------------------------------------------------------------------
|
---|
| 2 | // <autogenerated>
|
---|
| 3 | // This code was generated by a tool.
|
---|
| 4 | // Mono Runtime Version: 4.0.30319.1
|
---|
| 5 | //
|
---|
| 6 | // Changes to this file may cause incorrect behavior and will be lost if
|
---|
| 7 | // the code is regenerated.
|
---|
| 8 | // </autogenerated>
|
---|
| 9 | // ------------------------------------------------------------------------------
|
---|
| 10 | using System;
|
---|
| 11 | using System.Collections;
|
---|
| 12 | using System.Collections.Generic;
|
---|
| 13 | using System.Serialization;
|
---|
| 14 | using System.Diagnostics;
|
---|
| 15 |
|
---|
| 16 | namespace Kadecot
|
---|
| 17 | {
|
---|
| 18 | public class WampDeserializer
|
---|
| 19 | {
|
---|
| 20 | public WampDeserializer()
|
---|
| 21 | {
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public static object Parse(string msg)
|
---|
| 25 | {
|
---|
| 26 | object data;
|
---|
| 27 | if (msg == null || msg.Equals("")) throw new ArgumentNullException();
|
---|
| 28 |
|
---|
| 29 | Debug.WriteLine("[wamp perser] message received" + msg);
|
---|
| 30 | data = Json.Parse(msg);
|
---|
| 31 | if (!(data is IList<object>) ||
|
---|
| 32 | ((data is IList<object>) && ((List<object>)data).Count < 2)) {
|
---|
| 33 | return null;
|
---|
| 34 | }
|
---|
| 35 | List<object> list = (List<object>)data;
|
---|
| 36 | switch ((Int64)(list[0])) {
|
---|
| 37 | case (Int64)WAMP_MSG_TYPE.HELLO:
|
---|
| 38 | // WAMP SPEC: [HELLO, Realm|uri, Details|dict]
|
---|
| 39 | if (((List<object>)data).Count < 3) {
|
---|
| 40 | return null;
|
---|
| 41 | }
|
---|
| 42 | break;
|
---|
| 43 | case (Int64)WAMP_MSG_TYPE.WELCOME:
|
---|
| 44 | // WAMP SPEC: [WELCOME, Session|id, Details|dict]
|
---|
| 45 | if (((List<object>)data).Count < 3) {
|
---|
| 46 | return null;
|
---|
| 47 | }
|
---|
| 48 | break;
|
---|
| 49 | case (Int64)WAMP_MSG_TYPE.ABORT:
|
---|
| 50 | // WAMP SPEC: [ABORT, Details|dict, Reason|uri]
|
---|
| 51 | if (((List<object>)data).Count < 3) {
|
---|
| 52 | return null;
|
---|
| 53 | }
|
---|
| 54 | break;
|
---|
| 55 | case (int)WAMP_MSG_TYPE.CHALLENGE:
|
---|
| 56 | // advanced WAMP SPEC: [CHALLENGE, AuthMethod|string, Extra|dict]
|
---|
| 57 | if (((List<object>)data).Count < 3) {
|
---|
| 58 | return null;
|
---|
| 59 | }
|
---|
| 60 | break;
|
---|
| 61 | case (int)WAMP_MSG_TYPE.AUTHENTICATE:
|
---|
| 62 | // advanced WAMP SPEC: [CHALLENGE, AuthMethod|string, Extra|dict]
|
---|
| 63 | if (((List<object>)data).Count < 3) {
|
---|
| 64 | return null;
|
---|
| 65 | }
|
---|
| 66 | break;
|
---|
| 67 | case (int)WAMP_MSG_TYPE.GOODBYE:
|
---|
| 68 | // WAMP SPEC: [GOODBYE, Details|dict, Reason|uri]
|
---|
| 69 | if (((List<object>)data).Count < 3) {
|
---|
| 70 | return null;
|
---|
| 71 | }
|
---|
| 72 | break;
|
---|
| 73 | case (int)WAMP_MSG_TYPE.HEARTBEAT:
|
---|
| 74 | // advanced WAMP SPEC: [AUTHENTICATE, Signature|string, Extra|dict]
|
---|
| 75 | if (((List<object>)data).Count < 3) {
|
---|
| 76 | return null;
|
---|
| 77 | }
|
---|
| 78 | break;
|
---|
| 79 | case (int)WAMP_MSG_TYPE.ERROR:
|
---|
| 80 | // WAMP SPEC: [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, (Arguments|list, ArgumentsKw|dict)]
|
---|
| 81 | if (((List<object>)data).Count < 5) {
|
---|
| 82 | return null;
|
---|
| 83 | }
|
---|
| 84 | switch ((int)((List<object>)data)[1]) {
|
---|
| 85 | case (int)WAMP_MSG_TYPE.GOODBYE:// add QUnit test
|
---|
| 86 | case (int)WAMP_MSG_TYPE.YIELD:// add QUnit test
|
---|
| 87 | case (int)WAMP_MSG_TYPE.ERROR:// add QUnit test
|
---|
| 88 | case (int)WAMP_MSG_TYPE.SUBSCRIBE:
|
---|
| 89 | case (int)WAMP_MSG_TYPE.UNSUBSCRIBE:
|
---|
| 90 | case (int)WAMP_MSG_TYPE.PUBLISH:
|
---|
| 91 | case (int)WAMP_MSG_TYPE.INVOCATION:
|
---|
| 92 | case (int)WAMP_MSG_TYPE.CALL:
|
---|
| 93 | break;
|
---|
| 94 | case (int)WAMP_MSG_TYPE.REGISTER:
|
---|
| 95 | case (int)WAMP_MSG_TYPE.UNREGISTER:
|
---|
| 96 | // WAMP SPEC: [ERROR, REGISTER, REGISTER.Request|id, Details|dict, Error|uri]
|
---|
| 97 | break;
|
---|
| 98 | default:
|
---|
| 99 | return null;
|
---|
| 100 | }
|
---|
| 101 | break;
|
---|
| 102 | case (int)WAMP_MSG_TYPE.PUBLISH:
|
---|
| 103 | // WAMP SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri]
|
---|
| 104 | // WAMP SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list]
|
---|
| 105 | // WAMP SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list, ArgumentsKw|dict]
|
---|
| 106 | if (((List<object>)data).Count < 4) {
|
---|
| 107 | return null;
|
---|
| 108 | }
|
---|
| 109 | break;
|
---|
| 110 | case (int)WAMP_MSG_TYPE.PUBLISHED:
|
---|
| 111 | // WAMP SPEC: [PUBLISHED, PUBLISH.Request|id, Publication|id]
|
---|
| 112 | if (((List<object>)data).Count < 3) {
|
---|
| 113 | return null;
|
---|
| 114 | }
|
---|
| 115 | break;
|
---|
| 116 | case (int)WAMP_MSG_TYPE.SUBSCRIBE:
|
---|
| 117 | // WAMP SPEC: [SUBSCRIBE, Request|id, Options|dict, Topic|uri]
|
---|
| 118 | if (((List<object>)data).Count < 4) {
|
---|
| 119 | return null;
|
---|
| 120 | }
|
---|
| 121 | break;
|
---|
| 122 | case (int)WAMP_MSG_TYPE.SUBSCRIBED:
|
---|
| 123 | // WAMP SPEC: [SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id]
|
---|
| 124 | if (((List<object>)data).Count < 3) {
|
---|
| 125 | return null;
|
---|
| 126 | }
|
---|
| 127 | break;
|
---|
| 128 | case (int)WAMP_MSG_TYPE.UNSUBSCRIBE:
|
---|
| 129 | // WAMP SPEC: [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id]
|
---|
| 130 | if (((List<object>)data).Count < 3) {
|
---|
| 131 | return null;
|
---|
| 132 | }
|
---|
| 133 | break;
|
---|
| 134 | case (int)WAMP_MSG_TYPE.UNSUBSCRIBED:
|
---|
| 135 | // WAMP SPEC: [UNSUBSCRIBED, UNSUBSCRIBE.Request|id]
|
---|
| 136 | if (((List<object>)data).Count < 2) {
|
---|
| 137 | return null;
|
---|
| 138 | }
|
---|
| 139 | break;
|
---|
| 140 | case (int)WAMP_MSG_TYPE.EVENT:
|
---|
| 141 | // WAMP SPEC: [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict]
|
---|
| 142 | // WAMP SPEC: [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list]
|
---|
| 143 | // WAMP SPEC: [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentKw|dict]
|
---|
| 144 | if (((List<object>)data).Count < 4) {
|
---|
| 145 | return null;
|
---|
| 146 | }
|
---|
| 147 | break;
|
---|
| 148 | case (int)WAMP_MSG_TYPE.CALL:
|
---|
| 149 | // WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri]
|
---|
| 150 | // WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list]
|
---|
| 151 | // WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list, ArgumentsKw|dict]
|
---|
| 152 | if (((List<object>)data).Count < 4) {
|
---|
| 153 | return null;
|
---|
| 154 | }
|
---|
| 155 | break;
|
---|
| 156 | case (int)WAMP_MSG_TYPE.CANCEL:
|
---|
| 157 | // advanced WAMP SPEC: [CANCEL, CALL.Request|id, Options|dict]
|
---|
| 158 | if (((List<object>)data).Count < 3) {
|
---|
| 159 | return null;
|
---|
| 160 | }
|
---|
| 161 | break;
|
---|
| 162 | case (int)WAMP_MSG_TYPE.RESULT:
|
---|
| 163 | // WAMP SPEC: [RESULT, CALL.Request|id, Details|dict]
|
---|
| 164 | // WAMP SPEC: [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list]
|
---|
| 165 | // WAMP SPEC: [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list, YIELD.ArgumentsKw|dict]
|
---|
| 166 | if (((List<object>)data).Count < 3) {
|
---|
| 167 | return null;
|
---|
| 168 | }
|
---|
| 169 | break;
|
---|
| 170 | case (int)WAMP_MSG_TYPE.REGISTER:
|
---|
| 171 | // WAMP SPEC: [REGISTER, Request|id, Options|dict, Procedure|uri]
|
---|
| 172 | if (((List<object>)data).Count < 4) {
|
---|
| 173 | return null;
|
---|
| 174 | }
|
---|
| 175 | break;
|
---|
| 176 | case (int)WAMP_MSG_TYPE.REGISTERED:
|
---|
| 177 | // WAMP SPEC: [REGISTERED, REGISTER.Request|id, Registration|id]
|
---|
| 178 | if (((List<object>)data).Count < 3) {
|
---|
| 179 | return null;
|
---|
| 180 | }
|
---|
| 181 | break;
|
---|
| 182 | case (int)WAMP_MSG_TYPE.UNREGISTER:
|
---|
| 183 | // WAMP SPEC: [UNREGISTER, Request|id, REGISTERED.Registration|id]
|
---|
| 184 | if (((List<object>)data).Count < 3) {
|
---|
| 185 | return null;
|
---|
| 186 | }
|
---|
| 187 | break;
|
---|
| 188 | case (int)WAMP_MSG_TYPE.UNREGISTERED:
|
---|
| 189 | // WAMP SPEC: [UNREGISTERED, UNREGISTER.Request|id]
|
---|
| 190 | if (((List<object>)data).Count < 2) {
|
---|
| 191 | return null;
|
---|
| 192 | }
|
---|
| 193 | break;
|
---|
| 194 | case (int)WAMP_MSG_TYPE.INVOCATION:
|
---|
| 195 | // WAMP SPEC: [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict]
|
---|
| 196 | // WAMP SPEC: [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list]
|
---|
| 197 | // WAMP SPEC: [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list, CALL.ArgumentsKw|dict]
|
---|
| 198 | if (((List<object>)data).Count < 4) {
|
---|
| 199 | return null;
|
---|
| 200 | }
|
---|
| 201 | break;
|
---|
| 202 | case (int)WAMP_MSG_TYPE.INTERRUPT:
|
---|
| 203 | // advanced WAMP SPEC: [INTERRUPT, INVOCATION.Request|id, Options|dict]
|
---|
| 204 | if (((List<object>)data).Count < 3) {
|
---|
| 205 | return null;
|
---|
| 206 | }
|
---|
| 207 | break;
|
---|
| 208 | case (int)WAMP_MSG_TYPE.YIELD:
|
---|
| 209 | // WAMP SPEC: [YIELD, INVOCATION.Request|id, Options|dict, (Arguments|list, ArgumentsKw|dict)]
|
---|
| 210 | if (((List<object>)data).Count < 3) {
|
---|
| 211 | return null;
|
---|
| 212 | }
|
---|
| 213 | break;
|
---|
| 214 | default:
|
---|
| 215 | return null;
|
---|
| 216 | }
|
---|
| 217 | return data;
|
---|
| 218 | }
|
---|
| 219 | }
|
---|
| 220 | }
|
---|