Skip to content

Commit

Permalink
Upgrade to Hunt 1.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Heromyth committed Mar 11, 2019
1 parent 2e8be82 commit d1ede40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions source/hunt/imf/io/client.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module hunt.imf.io.client;

import hunt.collection.ByteBuffer;
import hunt.net;

import hunt.imf.core.dispatcher;
Expand Down Expand Up @@ -47,9 +48,9 @@ class Client
if(_close !is null)
_close(context);
});
tcp.handler((in ubyte[] data){
tcp.handler((ByteBuffer buffer) {
auto context = cast(Context)tcp.getAttachment();
auto list = context.parser.consume(cast(byte[])data);
auto list = context.parser.consume(cast(byte[])buffer.getRemaining());
foreach(p ; list)
_dispatcher.dispatch(context , p);
});
Expand Down
4 changes: 2 additions & 2 deletions source/hunt/imf/io/context.d
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ void sendMessage(M)(Context context,int64_t message_id , M m , VoidHandler finis
{
auto packet = new Packet(message_id , m.toProtobuf.array);
auto data = packet.data;
context.sock.write(packet.data , finish);
context.sock.write(packet.data);
}

void sendMessage(Context context,int64_t message_id ,VoidHandler finish = null )
{
auto packet = new Packet(message_id);
auto data = packet.data;
context.sock.write(packet.data,finish);
context.sock.write(packet.data);
}

void close(Context context)
Expand Down
5 changes: 3 additions & 2 deletions source/hunt/imf/io/server.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module hunt.imf.io.server;

import hunt.collection.ByteBuffer;
import hunt.net;

import hunt.imf.core.dispatcher;
Expand Down Expand Up @@ -38,9 +39,9 @@ class Server
_close(context);
});
sock.handler(
(in ubyte[] data){
(ByteBuffer buffer) {
auto context = cast(Context)tcp.getAttachment();
auto list = context.parser.consume(cast(byte[])data);
auto list = context.parser.consume(cast(byte[])buffer.getRemaining());
foreach(p ; list)
_dispatcher.dispatch(context , p);
}
Expand Down

0 comments on commit d1ede40

Please sign in to comment.