Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions NetClient/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using MoreLinq;
using OpenEQ.Netcode;
using static System.Console;
Expand All @@ -11,8 +12,14 @@ static string Input(string prompt) {
}

static void Main(string[] args) {
while(true) {
var loginStream = new LoginStream(args[0], int.Parse(args[1]));
WriteLine("Starting NETClient");

var host = GetIndexValueOrDefault(args, 0, "127.0.0.1", (string value) => value);
var port = GetIndexValueOrDefault(args, 1, 5999, (string value) => int.Parse(value));
WriteLine($"Connecting to LoginServer @ {host}:{port}");

while(true) {
var loginStream = new LoginStream(host, port);
loginStream.LoginSuccess += (_, success) => {
if(success) {
WriteLine($"Login succeeded (accountID={loginStream.AccountID}). Requesting server list");
Expand Down Expand Up @@ -41,14 +48,26 @@ static void Main(string[] args) {
ConnectWorld(loginStream, server.Value);
};

loginStream.Login(Input("Username"), Input("Password"));
var username = Input("Username");
var password = Input("Password");

loginStream.Login(username, password);

while(!loginStream.Disconnecting)
Task.Delay(100).Wait();
}
}

static void ConnectWorld(LoginStream ls, ServerListElement server) {
private static TResult GetIndexValueOrDefault<TResult>(string[] args, int index, TResult defaultValue, Func<string, TResult> parser)
{
if (args.Length <= index)
{
return defaultValue;
}
return parser(args[index]);
}

static void ConnectWorld(LoginStream ls, ServerListElement server) {
WriteLine($"Selected {server}. Connecting.");
var worldStream = new WorldStream(server.WorldIP, 9000, ls.AccountID, ls.SessionKey);

Expand Down
Loading