Inheritance: SuperSocket.ClientEngine.ClientSession
 public TransferSocket(EndPoint endpoint, string fileName, string saveName)
 {
     readBuffer = new byte[PacketSize];
     _fileName = fileName;
     _saveName = saveName;
     var cmds = new UpLoadSocketCommandBase[] {
         new CheckFile(),
         new DoData(),
         new Text(),
     };
     foreach (var item in cmds)
         m_CommandDict.Add(item.Name, item);
     TcpClientSession client = new AsyncTcpSession(endpoint);
     client.Error += client_Error;
     client.DataReceived += client_DataReceived;
     client.Connected += client_Connected;
     client.Closed += client_Closed;
     Client = client;
     CommandReader = new TransferReader(this);
 }
Example #2
0
        void OnSessionConnected(object sender, EventArgs e)
        {
            m_Connected = true;

#if !SILVERLIGHT
            TcpClientSession session = sender as TcpClientSession;
            if (session != null)
            {
                m_LocalEndPoint = session.LocalEndPoint;
            }
#endif

            FinishConnectTask(true);

            var handler = Connected;
            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
 public void Dispose()
 {
     _fileName = string.Empty;
     if (m_fileStream != null)
     {
         m_fileStream.Close();
         m_fileStream = null;
     }
     var client = Client;
     if (client != null)
     {
         client.Error -= client_Error;
         client.DataReceived -= client_DataReceived;
         client.Connected -= client_Connected;
         client.Closed -= client_Closed;
         if (client.IsConnected)
             client.Close();
         Client = null;
     }
 }