Transfering ip address to trackingd is ok
This commit is contained in:
parent
58fec6f966
commit
9f6f711187
@ -1,5 +1,6 @@
|
|||||||
require "option_parser"
|
require "option_parser"
|
||||||
require "ipc"
|
require "ipc"
|
||||||
|
require "ipc/json"
|
||||||
require "socket"
|
require "socket"
|
||||||
require "./colors"
|
require "./colors"
|
||||||
|
|
||||||
@ -18,6 +19,15 @@ require "colorize"
|
|||||||
# All modifications to standard libraries go there.
|
# All modifications to standard libraries go there.
|
||||||
require "./lib_modifications.cr"
|
require "./lib_modifications.cr"
|
||||||
|
|
||||||
|
class Tracking::Request
|
||||||
|
IPC::JSON.message IpAddress, 1 do
|
||||||
|
property ipaddress : String?
|
||||||
|
|
||||||
|
def initialize(@ipaddress = nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Context
|
class Context
|
||||||
# service instance parameters
|
# service instance parameters
|
||||||
# they can be changed via the cli
|
# they can be changed via the cli
|
||||||
@ -221,15 +231,12 @@ def websocket_client_connection(client)
|
|||||||
|
|
||||||
sfd = Context.context.switchtable[client.fd]
|
sfd = Context.context.switchtable[client.fd]
|
||||||
Baguette::Log.info "trackingd - sending the IP address #{real_ip_address} to fd #{sfd}"
|
Baguette::Log.info "trackingd - sending the IP address #{real_ip_address} to fd #{sfd}"
|
||||||
# message = IPC::Message.from_json(JSON).to_packet
|
message = Tracking::Request::IpAddress.new real_ip_address
|
||||||
# => JSON has to include these attributes: mtype, utype, payload
|
|
||||||
# message = IPC::Message.new mtype, utype, payload
|
|
||||||
message = IPC::Message.new sfd, 1, 1.to_u8, "{\"ipaddress\": \"#{real_ip_address}\"}"
|
|
||||||
if Context.print_messages
|
if Context.print_messages
|
||||||
Baguette::Log.info "to trackingd: #{message.to_s}"
|
Baguette::Log.info "to trackingd: #{message.to_s}"
|
||||||
end
|
end
|
||||||
serv = WrappedTCPFileDescriptor.new(fd: sfd, family: Socket::Family::INET)
|
Context.service.send_now sfd, message
|
||||||
serv.send message.to_packet
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if Context.print_messages
|
if Context.print_messages
|
||||||
|
Loading…
Reference in New Issue
Block a user