using SwanCSharp.Sockets;
using System;
using System.Collections.Generic;
using System.Text;

namespace FileServer2
{
    class Program
    {
        private static FileServer mobjServer;

        static void Main(string[] args)
        {
            mobjServer = new FileServer("192.168.0.15", 18000, "", false);
            mobjServer.ReceiveData += new FileServer.ReceiveDataEventHandler(mobjServer_ReceiveData);
            mobjServer.OpenClientConnection += new FileServer.OpenClientConnectionEventHandler(mobjServer_OpenClientConnection);
        }

        private static void mobjServer_OpenClientConnection(string pstrIP, Int32 pintTCPPort)
        {
            Console.WriteLine("Connection accepted with IP: " + pstrIP + " - TCP Port: " + pintTCPPort.ToString());
        }

        private static void mobjServer_ReceiveData(string pstrFile, string pstrIP, Int32 pintTCPPort, Boolean pblnDownload, object pobjChannel)
        {
            if (pblnDownload)
            {
                Console.WriteLine("Requested download file " + pstrFile + " from IP: " + pstrIP + " - TCP Port: " + pintTCPPort.ToString());
            }
            else
            {
                Console.WriteLine("Requested upload file " + pstrFile + " from IP: " + pstrIP + " - TCP Port: " + pintTCPPort.ToString());
            }
        }
    }
}
