| | 1 | | using DCL; |
| | 2 | |
|
| | 3 | | public class SceneMessageUtilities |
| | 4 | | { |
| | 5 | | public static bool DecodePayloadChunk(string chunk, out string sceneId, out string message, out string tag) |
| | 6 | | { |
| 0 | 7 | | sceneId = message = tag = null; |
| | 8 | |
|
| 0 | 9 | | var separatorPosition = chunk.IndexOf('\t'); |
| | 10 | |
|
| 0 | 11 | | if (separatorPosition == -1) |
| | 12 | | { |
| 0 | 13 | | return false; |
| | 14 | | } |
| | 15 | |
|
| 0 | 16 | | sceneId = chunk.Substring(0, separatorPosition); |
| | 17 | |
|
| 0 | 18 | | var lastPosition = separatorPosition + 1; |
| 0 | 19 | | separatorPosition = chunk.IndexOf('\t', lastPosition); |
| | 20 | |
|
| 0 | 21 | | message = chunk.Substring(lastPosition, separatorPosition - lastPosition); |
| 0 | 22 | | lastPosition = separatorPosition + 1; |
| | 23 | |
|
| 0 | 24 | | separatorPosition = chunk.IndexOf('\t', lastPosition); |
| | 25 | |
|
| 0 | 26 | | message += '\t' + chunk.Substring(lastPosition, separatorPosition - lastPosition); |
| 0 | 27 | | lastPosition = separatorPosition + 1; |
| | 28 | |
|
| 0 | 29 | | tag = chunk.Substring(lastPosition); |
| | 30 | |
|
| 0 | 31 | | return true; |
| | 32 | | } |
| | 33 | |
|
| | 34 | | public static QueuedSceneMessage_Scene DecodeSceneMessage(string sceneId, string message, string tag) |
| | 35 | | { |
| 0 | 36 | | var queuedMessage = new QueuedSceneMessage_Scene() |
| | 37 | | { type = QueuedSceneMessage.Type.SCENE_MESSAGE, sceneId = sceneId, message = message, tag = tag }; |
| | 38 | |
|
| 0 | 39 | | var queuedMessageSeparatorIndex = queuedMessage.message.IndexOf('\t'); |
| | 40 | |
|
| 0 | 41 | | queuedMessage.method = queuedMessage.message.Substring(0, queuedMessageSeparatorIndex); |
| | 42 | |
|
| 0 | 43 | | return queuedMessage; |
| | 44 | | } |
| | 45 | | } |