1 /*
2  * MsgTrans - Message Transport Framework for DLang. Based on TCP, WebSocket, UDP transmission protocol.
3  *
4  * Copyright (C) 2019 HuntLabs
5  *
6  * Website: https://www.msgtrans.org
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module msgtrans.channel.TransportSession;
13 
14 import msgtrans.MessageBuffer;
15 import msgtrans.DefaultSessionManager;
16 
17 import hunt.util.Serialize;
18 import hunt.net;
19 import hunt.logging;
20 
21 import core.atomic;
22 import std.stdint;
23 import std.bitmanip;
24 
25 /** 
26  * 
27  */
28 abstract class TransportSession {
29 
30     private ulong _id;
31 
32     this(ulong id) {
33         _id = id;
34     }
35 
36     ulong id() {
37         return _id;
38     }
39 
40     Object getAttribute(string key);
41 
42     void setAttribute(string key, Object value);
43 
44     bool containsAttribute(string key);
45 
46     void send(MessageBuffer buffer);
47 
48     void send(uint messageId, string content) {
49         send(new MessageBuffer(messageId, cast(ubyte[]) content));
50     }
51 
52     void close();
53 
54     bool isConnected();
55 }