#!/usr/bin/perl -w

use lib "./lib";
use strict;
use warnings;
use Net::CyanChat::Server;

# Usage:
#   ccserver <host> <port>
#   ccserver <port>

my $host = "localhost";
my $port = 1812;
if (scalar(@ARGV) > 0) {
	$port = pop(@ARGV);
	$host = pop(@ARGV) if scalar(@ARGV) > 0;
}

# Create the server.
my $serv = new Net::CyanChat::Server (
	host  => $host,
	port  => $port,
	debug => 1,
);

# Set the admin password.
$serv->setPassword ("secret");

# Set some welcome messages.
$serv->setWelcome (
	"Welcome to Net::CyanChat::Server v. $Net::CyanChat::Server::VERSION",
	"",
	"The `ccserver` program is for testing purposes only.",
	"It's probably violation of copyright law",
	"to run a CyanChat server without permission",
	"from Cyan Worlds, so use at your own risk.",
);

$serv->connect();

# Loop.
print "Server running at $host:$port\n\n";
$serv->start();
