Show
Ignore:
Timestamp:
12/19/07 05:16:40 (13 months ago)
Author:
follower
Message:

Add guts of 'EchoServer?' state machine. (Currently unused.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/follower/wiz810mj/src/demo/WizDemo4/WizDemo4.pde

    r120 r121  
    424424  public: 
    425425    EchoServer(int port); 
     426    void next(); // TODO: Return something useful? 
    426427     
    427428  private: 
     
    440441} 
    441442   
     443void EchoServer::next() { 
     444  /* 
     445   
     446   */ 
     447 
     448  // TODO: Use better state machine implementation? 
     449    
     450  if (_state == ECHO_CONNECT_WAIT) { 
     451     
     452    if (_connection.isConnected()) { 
     453      _state = ECHO_CONNECTED; 
     454    } else { 
     455      // Keep waiting 
     456    } 
     457     
     458  } else if (_state == ECHO_CONNECTED) { 
     459     
     460    if (_connection.available()) { 
     461      _connection.print(_connection.read()); 
     462    } else if (!_connection.isConnected()) { 
     463       // Data finished and client disconnected  
     464       _state == ECHO_CLOSE; 
     465    } 
     466 
     467  } else if (_state == ECHO_CLOSE) { 
     468 
     469    _connection.close(); 
     470    _state = ECHO_HALT;     
     471 
     472  } else if (_state == ECHO_HALT) { 
     473      // Do nothing 
     474  } else { 
     475    // Unknown state, do nothing. 
     476  }   
     477} 
    442478   
    443479/* ----------------------- */