Less debug messages.
This commit is contained in:
parent
28d7dd8fc2
commit
ba6671d902
@ -284,8 +284,6 @@ pub const Context = struct {
|
||||
self.connections.items[index_destinataire].t = Connection.Type.SWITCHED;
|
||||
|
||||
try self.switchdb.add_switch(fd1,fd2);
|
||||
print("ADD SWITCH\n", .{});
|
||||
print("self: {}\n", .{self});
|
||||
}
|
||||
|
||||
pub fn set_switch_callbacks(self: *Self, fd: i32
|
||||
|
@ -16,6 +16,7 @@ const native_os = builtin.target.os.tag;
|
||||
const print = std.debug.print;
|
||||
const testing = std.testing;
|
||||
const print_eq = @import("./util.zig").print_eq;
|
||||
const URI = @import("./util.zig").URI;
|
||||
|
||||
// Standard library is unecessary complex regarding networking.
|
||||
// libipc drops it and uses plain old file descriptors instead.
|
||||
@ -135,33 +136,28 @@ fn create_service() !void {
|
||||
print("ERROR: no target in: {s}\n", .{next});
|
||||
}
|
||||
}
|
||||
// 3. connect whether asked to and send a message
|
||||
// TODO: currently only switching with other UNIX sockets ^^'.
|
||||
// Should contact <protocol>d.
|
||||
|
||||
// 3. connect whether asked to and send a message
|
||||
if (final_destination) |dest| {
|
||||
print("Let's contact {s} (original service requested: {s})\n"
|
||||
print("Let's contact {s} (service requested: {s})\n"
|
||||
, .{dest, service_to_contact});
|
||||
|
||||
var iterator3 = std.mem.split(u8, dest, "://");
|
||||
var protocol = iterator3.first();
|
||||
print("Protocol: {s}\n" , .{protocol});
|
||||
var uri = URI.read(dest);
|
||||
|
||||
// 1. in case there is no URI
|
||||
if (std.mem.eql(u8, protocol, dest)) {
|
||||
if (std.mem.eql(u8, uri.protocol, dest)) {
|
||||
var newfd = try ctx.connect_service (dest);
|
||||
send_fd (some_event.origin, "ok", newfd);
|
||||
try ctx.close_fd (newfd);
|
||||
}
|
||||
else if (std.mem.eql(u8, protocol, "unix")) {
|
||||
var newfd = try ctx.connect_service (iterator3.next().?);
|
||||
else if (std.mem.eql(u8, uri.protocol, "unix")) {
|
||||
var newfd = try ctx.connect_service (uri.address);
|
||||
send_fd (some_event.origin, "ok", newfd);
|
||||
try ctx.close_fd (newfd);
|
||||
}
|
||||
// 2. else, contact <protocol>d or directly the dest in case there is none.
|
||||
else {
|
||||
print("should contact {s}d: TODO\n", .{protocol});
|
||||
var servicefd = try ctx.connect_service (protocol);
|
||||
var servicefd = try ctx.connect_service (uri.protocol);
|
||||
defer ctx.close_fd (servicefd) catch {};
|
||||
// TODO: make a simple protocol between IPCd and <protocol>d
|
||||
// NEED inform about the connection (success or fail)
|
||||
@ -178,7 +174,7 @@ fn create_service() !void {
|
||||
defer r.deinit();
|
||||
if (std.mem.eql(u8, r.payload, "ok")) {
|
||||
// OK
|
||||
print("service has established the connection\n", .{});
|
||||
// print("service has established the connection\n", .{});
|
||||
send_fd (some_event.origin, "ok", servicefd);
|
||||
}
|
||||
else if (std.mem.eql(u8, r.payload, "ne")) {
|
||||
|
@ -256,7 +256,7 @@ test "nuke 'em" {
|
||||
}
|
||||
|
||||
fn default_in (origin: i32, m: *Message) CBEventType {
|
||||
print ("receiving a message originated from {}\n", .{origin});
|
||||
// print ("receiving a message originated from {}\n", .{origin});
|
||||
var buffer: [2000000]u8 = undefined; // TODO: FIXME??
|
||||
var packet_size: usize = undefined;
|
||||
|
||||
@ -275,8 +275,8 @@ fn default_in (origin: i32, m: *Message) CBEventType {
|
||||
return CBEventType.NO_ERROR;
|
||||
}
|
||||
|
||||
fn default_out (origin: i32, m: *const Message) CBEventType {
|
||||
print ("sending a message originated from {}\n", .{origin});
|
||||
fn default_out (_: i32, m: *const Message) CBEventType {
|
||||
// print ("sending a message originated from {}\n", .{origin});
|
||||
// Message contains the fd, no need to search for
|
||||
// the right structure to copy, let's just recreate
|
||||
// a Stream from the fd.
|
||||
|
Reference in New Issue
Block a user