| 1 |
#Region "Microsoft.VisualBasic::758cc9918a9da55982bf9c28321da545, Microsoft.VisualBasic.Core\Net\Tcp\Persistent\Protocols\Protocol.vb"
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
#End Region
|
| 55 |
|
| 56 |
Imports System.Runtime.CompilerServices
|
| 57 |
Imports Microsoft.VisualBasic.Net.Protocols
|
| 58 |
Imports Microsoft.VisualBasic.Net.Protocols.Reflection
|
| 59 |
|
| 60 |
Namespace Net.Tcp.Persistent.Application.Protocols
|
| 61 |
|
| 62 |
Public Module ServicesProtocol
|
| 63 |
|
| 64 |
Public Enum Protocols As Long
|
| 65 |
Logon = 59867
|
| 66 |
ServerHash
|
| 67 |
SendMessage
|
| 68 |
ConfigConnection
|
| 69 |
IsUserOnline
|
| 70 |
GetMyIPAddress
|
| 71 |
Broadcast
|
| 72 |
End Enum
|
| 73 |
|
| 74 |
Public ReadOnly Property EntryPoint As Long = New Protocol(GetType(Protocols)).EntryPoint
|
| 75 |
|
| 76 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
| 77 |
Public Function SendChannelHashCode(hash As Integer) As RequestStream
|
| 78 |
Return New RequestStream(EntryPoint, Protocols.ServerHash, CStr(hash))
|
| 79 |
End Function
|
| 80 |
|
| 81 |
Public Const WorkSocketPortal As Integer = 66982
|
| 82 |
|
| 83 |
Public Function LogOnRequest(USER_ID As Long, Socket As String) As RequestStream
|
| 84 |
Dim post As String = New LogonPOST With {
|
| 85 |
.Socket = Socket,
|
| 86 |
.USER_ID = USER_ID
|
| 87 |
}.GetXml
|
| 88 |
Return New RequestStream(EntryPoint, Protocols.Logon, post)
|
| 89 |
End Function
|
| 90 |
|
| 91 |
Public Function GetLogOnUSER(request As String, ByRef USER_ID As Long, ByRef Socket As String) As Boolean
|
| 92 |
Dim post As LogonPOST = request.LoadFromXml(Of LogonPOST)(False)
|
| 93 |
|
| 94 |
If post Is Nothing Then
|
| 95 |
Return False
|
| 96 |
Else
|
| 97 |
USER_ID = post.USER_ID
|
| 98 |
Socket = post.Socket
|
| 99 |
|
| 100 |
Return USER_ID <> 0 AndAlso Not String.IsNullOrEmpty(Socket)
|
| 101 |
End If
|
| 102 |
End Function
|
| 103 |
|
| 104 |
Public Function SendMessageRequest([FROM] As Long, USER_ID As Long, Message As RequestStream) As RequestStream
|
| 105 |
Dim post As New SendMessagePost With {
|
| 106 |
.FROM = FROM,
|
| 107 |
.Message = Message,
|
| 108 |
.USER_ID = USER_ID
|
| 109 |
}
|
| 110 |
Return New RequestStream(EntryPoint, Protocols.SendMessage, post.Serialize)
|
| 111 |
End Function
|
| 112 |
|
| 113 |
Public Function GetSendMessage(request As RequestStream, ByRef [FROM] As Long, ByRef USER_ID As Long) As Boolean
|
| 114 |
Dim post As SendMessagePost = New SendMessagePost(request.ChunkBuffer)
|
| 115 |
|
| 116 |
[FROM] = post.FROM
|
| 117 |
USER_ID = post.USER_ID
|
| 118 |
|
| 119 |
Return True
|
| 120 |
End Function
|
| 121 |
|
| 122 |
Public Function GetServicesConnection() As RequestStream
|
| 123 |
Return New RequestStream(EntryPoint, Protocols.ConfigConnection, "GET")
|
| 124 |
End Function
|
| 125 |
|
| 126 |
Public Function IsUserOnlineRequest(USER_ID As Long) As RequestStream
|
| 127 |
Return New RequestStream(EntryPoint, Protocols.IsUserOnline, CStr(USER_ID))
|
| 128 |
End Function
|
| 129 |
|
| 130 |
Public Function BroadcastMessage(USER_ID As Long, Message As RequestStream) As RequestStream
|
| 131 |
Dim post As New BroadcastPOST With {
|
| 132 |
.Message = Message,
|
| 133 |
.USER_ID = USER_ID
|
| 134 |
}
|
| 135 |
Return New RequestStream(EntryPoint, Protocols.Broadcast, post.Serialize)
|
| 136 |
End Function
|
| 137 |
End Module
|
| 138 |
End Namespace
|