do more test
This commit is contained in:
parent
ca51e2d7e1
commit
52bee8473d
|
@ -8,10 +8,10 @@ fn dumpDebug(name: []const u8, list: std.ArrayList(u8)) !void {
|
|||
|
||||
const file = try std.fs.cwd().createFile(
|
||||
name,
|
||||
.{ .truncate = false },
|
||||
.{ .truncate = true },
|
||||
);
|
||||
defer file.close();
|
||||
|
||||
try file.seekTo(0);
|
||||
try file.writeAll(list.items);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ pub const Client = struct {
|
|||
var list = std.ArrayList(u8).init(s.allocator);
|
||||
|
||||
var map = std.StringHashMap(qvar.QVariant).init(s.allocator);
|
||||
|
||||
try map.put("UseSSL", .{ .byte = 0 });
|
||||
try map.put("UseCompression", .{ .byte = 0 });
|
||||
try map.put("ProtocolVersion", .{ .int = 10 });
|
||||
|
|
|
@ -7,7 +7,7 @@ const initClient = @import("./client.zig").initClient;
|
|||
|
||||
pub fn main() !void {
|
||||
const allocator = std.heap.page_allocator;
|
||||
var sock = try std.net.tcpConnectToHost(allocator, "127.0.0.1", 64242);
|
||||
var sock = try std.net.tcpConnectToHost(allocator, "127.0.0.1", 4242);
|
||||
|
||||
var client = initClient(allocator, &sock);
|
||||
try client.handshake();
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn qvariant_type_id(variant: QVariant) !u32 {
|
|||
return @enumToInt(QVariantTypes.byte);
|
||||
},
|
||||
.int => {
|
||||
return @enumToInt(QVariantTypes.int_1);
|
||||
return @enumToInt(QVariantTypes.int_2);
|
||||
},
|
||||
.qmap => {
|
||||
return @enumToInt(QVariantTypes.qmap);
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn add_bytearray(writer: anytype, array: std.ArrayList(u8)) !void {
|
|||
}
|
||||
|
||||
pub fn add_string(writer: anytype, allocator: *std.mem.Allocator, str: []const u8) !void {
|
||||
try writer.writeIntBig(i32, @intCast(i32, str.len));
|
||||
try writer.writeIntBig(i32, @intCast(i32, str.len*16));
|
||||
var ut16Str = try allocator.alloc(u16, str.len);
|
||||
defer allocator.free(ut16Str);
|
||||
for (str) |character, index| {
|
||||
|
@ -94,7 +94,7 @@ pub fn add_message(writer: anytype, allocator: *std.mem.Allocator, map: std.Stri
|
|||
var data = std.ArrayList(u8).init(allocator);
|
||||
try add_qvariantmap(data.writer(), allocator, map);
|
||||
|
||||
try add_int(writer, @intCast(u32, data.items.len) * 8);
|
||||
try add_int(writer, @intCast(u32, data.items.len * 8));
|
||||
|
||||
try writer.writeAll(data.items);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue