refactor io
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <examples/PacketExample.h>
|
||||
#include <sp/io/FileIO.h>
|
||||
#include <sp/io/File.h>
|
||||
|
||||
class CustomPacketHandler : public sp::PacketHandler {
|
||||
void Handle(const KeepAlivePacket& packet) {
|
||||
@@ -17,13 +17,12 @@ class CustomPacketHandler : public sp::PacketHandler {
|
||||
}
|
||||
};
|
||||
|
||||
using FileStream = sp::IOStream<sp::FileTag, sp::PacketDispatcher, sp::PacketFactory>;
|
||||
|
||||
using FileStream = sp::io::Stream<sp::io::FileTag, sp::PacketDispatcher, sp::PacketFactory>;
|
||||
|
||||
int main() {
|
||||
auto handler = std::make_shared<CustomPacketHandler>();
|
||||
|
||||
FileStream stream(sp::FileIO{"test.txt", "text.txt"});
|
||||
FileStream stream(sp::io::File{"test.txt", sp::io::FileTag::In | sp::io::FileTag::Out});
|
||||
stream.GetDispatcher().RegisterHandler(PacketId::Disconnect, handler);
|
||||
stream.GetDispatcher().RegisterHandler(PacketId::KeepAlive, handler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user