Skip to content

Commit f49de9d

Browse files
committed
Added different options for connecting to gotham on unix and windows
1 parent 74e5788 commit f49de9d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/gotham_module.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use crate::{
2-
connection::{BaseConnection, Buffer},
2+
connection::{BaseConnection, Buffer, InetSocketConnection},
33
models::{BaseMessage, Value},
44
protocol::BaseProtocol,
55
utils::{self, Error, Result},
66
};
77

88
#[cfg(target_family = "unix")]
99
use crate::connection::UnixSocketConnection;
10-
#[cfg(target_family = "windows")]
11-
use crate::connection::InetSocketConnection;
1210

1311
use std::collections::HashMap;
1412
use async_std::{
@@ -51,10 +49,22 @@ impl GothamModule {
5149
}
5250

5351
#[cfg(target_family = "windows")]
54-
pub fn default(port: String) -> Self {
52+
pub fn default(port: u16) -> Self {
5553
GothamModule {
5654
protocol: BaseProtocol::default(),
57-
connection: Box::new(InetSocketConnection::new(port)),
55+
connection: Box::new(InetSocketConnection::new(format!("127.0.0.1:{}", port))),
56+
requests: Arc::new(Mutex::new(HashMap::new())),
57+
functions: Arc::new(Mutex::new(HashMap::new())),
58+
hook_listeners: Arc::new(Mutex::new(HashMap::new())),
59+
message_buffer: vec![],
60+
registered: false,
61+
}
62+
}
63+
64+
pub fn with_inet_socket(socket: String) -> Self {
65+
GothamModule {
66+
protocol: BaseProtocol::default(),
67+
connection: Box::new(InetSocketConnection::new(socket)),
5868
requests: Arc::new(Mutex::new(HashMap::new())),
5969
functions: Arc::new(Mutex::new(HashMap::new())),
6070
hook_listeners: Arc::new(Mutex::new(HashMap::new())),

0 commit comments

Comments
 (0)