joshwingreene
5/22/2015 - 5:16 PM

Inf 124 - Proj 2 - Testing State, Chat Session, Client Classes

Inf 124 - Proj 2 - Testing State, Chat Session, Client Classes

import model

if __name__ == '__main__':

    state = model.State()

    print('visitor')
    visitor = model.Visitor('localhost', 8888) # a listener on the server should increment the number of clients
    visitor.set_up_client()

    print('agent')
    agent = model.Agent('localhost', 8888)
    agent.set_up_client()

    print('add to new chat session')
    session_timestamp = state.add_new_chat_session(visitor, agent)

    visitor.set_active_timestamp(session_timestamp)
    agent.set_active_timestamp(session_timestamp)

    print(state.chatSessions)

    print('log messages')

    state.log_message(session_timestamp, agent.client_name, "Hello")
    state.log_message(session_timestamp, visitor.client_name, "I need help!")

    state.print_session_transcript(session_timestamp)

    print('end chat session')

    state.end_chat_session(session_timestamp)

    print('Is the chat session active? - ' + str(state.chatSessions[session_timestamp].isActive))