@@ -48,13 +48,13 @@ public void SetPort(int port)
48
48
_kcpService = new KcpService ( _port , ReceiveMessage ) ;
49
49
}
50
50
51
- public Task < IResponse > Call ( IRequest message , IPEndPoint endPoint )
51
+ public Task < T > Call < T > ( IRequest message , IPEndPoint endPoint ) where T : class , IResponse
52
52
{
53
- var task = new TaskCompletionSource < IResponse > ( ) ;
53
+ var task = new TaskCompletionSource < T > ( ) ;
54
54
message . RpcId = ++ _rpcId ;
55
55
_responseCallback [ message . RpcId ] = ( msg ) =>
56
56
{
57
- IResponse response = msg as IResponse ;
57
+ T response = msg as T ;
58
58
task . SetResult ( response ) ;
59
59
} ;
60
60
SendMessage ( message , endPoint ) ;
@@ -69,10 +69,15 @@ public void SendMessage(object message,IPEndPoint endPoint)
69
69
if ( attribute . Length <= 0 )
70
70
throw new GamekException ( "class not found MessageAttribute" ) ;
71
71
MessageAttribute mgAttribute = ( MessageAttribute ) attribute [ 0 ] ;
72
+
73
+ SendMessage ( mgAttribute . TypeCode , messageData , endPoint ) ;
74
+ }
72
75
73
- _kcpService ? . SendMessage ( mgAttribute . TypeCode , messageData , endPoint ) ;
76
+ public void SendMessage ( ushort typeCode , byte [ ] messageData , IPEndPoint endPoint )
77
+ {
78
+ _kcpService ? . SendMessage ( typeCode , messageData , endPoint ) ;
74
79
}
75
-
80
+
76
81
public void OnUpdate ( )
77
82
{
78
83
_kcpService ? . Update ( ) ;
@@ -100,7 +105,7 @@ private void LoadMessageAttribute()
100
105
101
106
//get message
102
107
attribute = item . GetCustomAttributes ( typeof ( MessageAttribute ) , false ) ;
103
- if ( attribute . Length > 0 && ! item . IsAbstract && item . BaseType == typeof ( IMessage ) )
108
+ if ( attribute . Length > 0 && ! item . IsAbstract )
104
109
{
105
110
MessageAttribute msAttibute = ( MessageAttribute ) attribute [ 0 ] ;
106
111
_messageCodeType [ msAttibute . TypeCode ] = item ;
0 commit comments