Naming consistency fixed (MESSAGE_TX and MESSAGE_RX).

master
Philippe Pittoli 2023-01-20 23:12:04 +01:00
parent da27ce33dd
commit 3e3d996e7b
7 changed files with 23 additions and 23 deletions

View File

@ -107,7 +107,7 @@ fn create_service() !void {
break; break;
}, },
.MESSAGE => { .MESSAGE_RX => {
print("Client asking for a service through ipcd.\n", .{}); print("Client asking for a service through ipcd.\n", .{});
defer ctx.close_fd (some_event.origin) catch {}; defer ctx.close_fd (some_event.origin) catch {};
if (some_event.m) |m| { if (some_event.m) |m| {
@ -206,7 +206,7 @@ fn create_service() !void {
} }
}, },
.TX => { .MESSAGE_TX => {
print("Message sent.\n", .{}); print("Message sent.\n", .{});
}, },

View File

@ -43,7 +43,7 @@ pub fn main() !u8 {
print("Timer!\n", .{}); print("Timer!\n", .{});
}, },
.MESSAGE => { .MESSAGE_RX => {
if (some_event.m) |m| { if (some_event.m) |m| {
print("message has been bounced: {}\n", .{m}); print("message has been bounced: {}\n", .{m});
m.deinit(); m.deinit();
@ -55,7 +55,7 @@ pub fn main() !u8 {
} }
}, },
.TX => { .MESSAGE_TX => {
print("Message sent.\n", .{}); print("Message sent.\n", .{});
}, },

View File

@ -79,7 +79,7 @@ fn create_service() !void {
, .{some_event.origin, ctx.pollfd.items.len}); , .{some_event.origin, ctx.pollfd.items.len});
}, },
.MESSAGE => { .MESSAGE_RX => {
if (some_event.m) |m| { if (some_event.m) |m| {
print("New message ({} bytes)\n", .{m.payload.len}); print("New message ({} bytes)\n", .{m.payload.len});
util.print_message ("RECEIVED MESSAGE", m); util.print_message ("RECEIVED MESSAGE", m);
@ -92,7 +92,7 @@ fn create_service() !void {
} }
}, },
.TX => { .MESSAGE_TX => {
print("Message sent.\n", .{}); print("Message sent.\n", .{});
}, },

View File

@ -185,7 +185,7 @@ fn create_service() !void {
print ("Message has been sent (SWITCH fd {}).\n", .{some_event.origin}); print ("Message has been sent (SWITCH fd {}).\n", .{some_event.origin});
}, },
.MESSAGE => { .MESSAGE_RX => {
print ("Client asking for a service through TCPd.\n", .{}); print ("Client asking for a service through TCPd.\n", .{});
errdefer ctx.close (some_event.index) catch {}; errdefer ctx.close (some_event.index) catch {};
if (some_event.m) |m| { if (some_event.m) |m| {
@ -240,7 +240,7 @@ fn create_service() !void {
} }
}, },
.TX => { .MESSAGE_TX => {
print ("Message sent.\n", .{}); print ("Message sent.\n", .{});
}, },

View File

@ -5,14 +5,14 @@
enum event_types { enum event_types {
ERROR = 0 // A problem occured. ERROR = 0 // A problem occured.
, EXTERNAL = 1 // Message received from a non IPC socket. , CONNECTION = 1 // New user.
, SWITCH_RX = 2 // Message received from a switched FD. , DISCONNECTION = 2 // User disconnected.
, SWITCH_TX = 3 // Message sent to a switched fd. , MESSAGE_RX = 3 // New message.
, CONNECTION = 4 // New user. , MESSAGE_TX = 4 // Message sent.
, DISCONNECTION = 5 // User disconnected. , TIMER = 5 // Timeout in the poll(2) function.
, MESSAGE = 6 // New message. , EXTERNAL = 6 // Message received from a non IPC socket.
, TIMER = 7 // Timeout in the poll(2) function. , SWITCH_RX = 7 // Message received from a switched FD.
, TX = 8 // Message sent. , SWITCH_TX = 8 // Message sent to a switched fd.
}; };
// Return type of callback functions when switching. // Return type of callback functions when switching.

View File

@ -439,7 +439,7 @@ pub const Context = struct {
}; };
if (maybe_message) |m| { if (maybe_message) |m| {
return Event.init(Event.Type.MESSAGE, i, fd.fd, m); return Event.init(Event.Type.MESSAGE_RX, i, fd.fd, m);
} }
try self.close(i); try self.close(i);
@ -486,7 +486,7 @@ pub const Context = struct {
// otherwise = write message for the msg.fd // otherwise = write message for the msg.fd
try self.write (m); try self.write (m);
m.deinit(); m.deinit();
return Event.init(Event.Type.TX, i, fd.fd, null); return Event.init(Event.Type.MESSAGE_TX, i, fd.fd, null);
} }
} }
// .revent is POLLHUP // .revent is POLLHUP

View File

@ -35,14 +35,14 @@ pub const Event = struct {
pub const Type = enum { pub const Type = enum {
ERROR, // A problem occured. ERROR, // A problem occured.
CONNECTION, // New user.
DISCONNECTION, // User disconnected.
MESSAGE_RX, // New message.
MESSAGE_TX, // Message sent.
TIMER, // Timeout in the poll(2) function.
EXTERNAL, // Message received from a non IPC socket. EXTERNAL, // Message received from a non IPC socket.
SWITCH_RX, // Message received from a switched FD. SWITCH_RX, // Message received from a switched FD.
SWITCH_TX, // Message sent to a switched fd. SWITCH_TX, // Message sent to a switched fd.
CONNECTION, // New user.
DISCONNECTION, // User disconnected.
MESSAGE, // New message.
TIMER, // Timeout in the poll(2) function.
TX, // Message sent.
}; };
t: Event.Type, t: Event.Type,