diff --git a/README.md b/README.md
deleted file mode 100644
index 5312ccf..0000000
--- a/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# TCP Talk
-Talk app that uses tcp in the backend
-
-## Features
-1. Simple Chat
-You can chat, simplelest feature
-
-2. Color coding
-Send messages with colors
-`Hello World.green` the `.green` puts the text in green
-
-3. Config file for server and client
-You can configure your server and your client with two JSON files.
-
-## More Info
-
-### Color Coding
-Sending messages with colors works like this:
-`Hello World.green` the `.green` puts the text in green
-
-Other avalible colors are:
- **color** ascii color code
- **black**: 30
- **red**: 31
- **green**: 32
- **yellow**: 33
- **blue**: 34
- **magenta**: 35
- **cyan**: 36
- **white**: 37
-
-### Server Config
-The server configuration file `server-config.json` is a JSON file to configure you server:
-```
-{
- "server_name": "tcp-test-server",
- "port": 4000
-}
-```
-### Client Config
-The client configuration file `client-config.json` is a JSON file to configure you client:
-```
-{
- "hostname": "localhost",
- "port": 4000,
- "username": "user"
-}
-
-```
\ No newline at end of file
diff --git a/cli.png b/cli.png
new file mode 100644
index 0000000..065e10a
Binary files /dev/null and b/cli.png differ
diff --git a/client-config.json b/client-config.json
deleted file mode 100644
index b0c52d5..0000000
--- a/client-config.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "hostname": "localhost",
- "port": 4000,
- "username": "tcp-user"
-}
diff --git a/tcp-client.rb b/connector.rb
old mode 100644
new mode 100755
similarity index 51%
rename from tcp-client.rb
rename to connector.rb
index 1d6dd5c..0480ac6
--- a/tcp-client.rb
+++ b/connector.rb
@@ -1,5 +1,5 @@
-require 'socket'
require 'json'
+require 'socket'
# Get colors working
class String
@@ -24,6 +24,7 @@ class String
default_hostname = 'localhost'
default_port = 4000
default_username = 'default_user'
+server= '(Server)'
begin
# Attempt to read and parse the configuration file
@@ -32,7 +33,7 @@ class String
# Extract configuration values
hostname = config['hostname']
port = config['port']
- username = config['username']
+ @my_username = config['username']
rescue Errno::ENOENT, JSON::ParserError
# If the file is not found or there's a JSON parsing error, use default values
puts "(Client) Error reading configuration file. Using default values.".yellow
@@ -45,51 +46,37 @@ class String
puts "You can use 'config.json' if you want to preconfigure this"
end
-begin
- socket = TCPSocket.open(hostname, port)
- puts "(Client) Connected to server at --> #{hostname}:#{port}".yellow
-
-
-rescue Errno::ECONNREFUSED
- puts "(Client) Error: Connection refused. Please ensure the server is running and try again. Host Server:#{hostname} Host Server Port:#{port}".yellow
- exit
-end
-
-# Handle Ctrl+C (SIGINT) to gracefully shut down the client
-trap("INT") do
- puts "\n (Client) Disconnecting from server...".yellow
- socket.puts "exit" rescue nil
- socket.close
- exit
-end
-
-Thread.new do
- loop do
- msg = socket.gets
- if msg.nil?
- puts "(Client) Connection closed by server.".yellow
- exit
- else
- msg.chomp!
+# Start the connection
+def start_connection(hostname, port, username, text_view)
+ begin
+ socket = TCPSocket.open(hostname, port)
+ puts "(Client) Connected to server at --> #{hostname}:#{port}".yellow
- # Detect and apply color
- if msg.match(/\.\w+$/)
- color_code = msg.match(/\.(\w+)$/)[1]
- if String::COLORS.key?(color_code.to_sym)
- colored_msg = msg.gsub(/\.\w+$/, '').send(color_code.to_sym)
- puts colored_msg
+ Thread.new do
+ loop do
+ msg = socket.gets
+ if msg.nil?
+ puts "(Client) Connection closed by server.".yellow
+ exit
else
- puts msg
+ msg.chomp!
+
+ # Update the text buffer of the text_view on the GTK main thread
+ GLib::Idle.add do
+ buffer = text_view.buffer
+ iter = buffer.end_iter
+ buffer.insert(iter, "#{@my_username}: #{msg}" + "\n")
+ text_view.scroll_to_iter(iter, 0, false, 0, 1)
+ false
+ end
end
- else
- puts msg
end
end
- end
-end
-loop do
- msg = $stdin.gets.chomp
- break if msg == "exit"
- socket.puts "#{username}:#{msg}"
+
+ return socket
+ rescue Errno::ECONNREFUSED
+ puts "(Client) Error: Connection refused. Please ensure the server is running and try again. Host Server:#{hostname} Host Server Port:#{port}".yellow
+ exit
+ end
end
diff --git a/main.glade b/main.glade
new file mode 100644
index 0000000..b3d6fec
--- /dev/null
+++ b/main.glade
@@ -0,0 +1,104 @@
+
+
+
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: