Browse Source

core, discovery, packet: WIP

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
bboozzoo/self-announce
Maciek Borzecki 7 years ago
parent
commit
504e3a7ce9
3 changed files with 10 additions and 5 deletions
  1. +4
    -4
      src/mconnect/core.vala
  2. +2
    -0
      src/mconnect/discovery.vala
  3. +4
    -1
      src/mconnect/packet.vala

+ 4
- 4
src/mconnect/core.vala View File

@ -31,9 +31,7 @@ class Core : Object {
public static string device_id {
owned get {
string host_name = Environment.get_host_name();
string user = Environment.get_user_name();
return @"$user@host_name";
return Environment.get_host_name();
}
private set {}
@ -41,7 +39,9 @@ class Core : Object {
public static string device_name {
owned get {
return Environment.get_host_name();
string host_name = Environment.get_host_name();
string user = Environment.get_user_name();
return @"$user@$host_name";
}
private set {}
}


+ 2
- 0
src/mconnect/discovery.vala View File

@ -101,6 +101,7 @@ class Discovery : GLib.Object
var sock = new Socket(SocketFamily.IPV4,
SocketType.DATAGRAM,
SocketProtocol.UDP);
sock.broadcast = true;
try {
var sa = new InetSocketAddress(new InetAddress.from_string("255.255.255.255"),
1716);
@ -112,6 +113,7 @@ class Discovery : GLib.Object
core.handlers.interfaces,
core.handlers.interfaces);
debug("identity: %s", identity.to_string());
sock.send_to(sa, identity.to_string().data);
} catch (Error e) {
warning("failed to send annoucement: %s", e.message);


+ 4
- 1
src/mconnect/packet.vala View File

@ -132,7 +132,8 @@ class Packet : GLib.Object {
string device_id,
string[] in_interfaces,
string[] out_interfaces,
string device_type = "desktop") {
string device_type = "desktop",
uint tcp_port = 1716) {
var builder = new Json.Builder();
builder.begin_object();
builder.set_member_name("deviceName");
@ -147,6 +148,8 @@ class Packet : GLib.Object {
builder.add_string_value(string.joinv(",", out_interfaces));
builder.set_member_name("protocolVersion");
builder.add_int_value(PROTOCOL_VERSION);
builder.set_member_name("tcpPort");
builder.add_int_value(tcp_port);
builder.end_object();
Json.Object data_obj = builder.get_root().get_object();


Loading…
Cancel
Save