/*
 * Copyright (C) 2008 The Trustees of Columbia University in the City of New York. 
 * All rights reserved.
 *
 * See the file LICENSE included in this distribution for details.
 */

#ifndef _MAINTHELPER_H
#define _MAINTHELPER_H

#include "trace.h"
#include "types.h"
#include "rmanager.h"



class MaintHelper {

 private:
  Peer* m_pPeer;
  RManager* m_pRM;

  //Inprogress table
  map<string, LObject> m_IP;

 public:
  MaintHelper();
  ~MaintHelper();  

  void setParams(Peer* pPeer, RManager* pRM);

  int32 OnJoinRequest(struct message& msg, char* pchIP, int32 port, transtype tt);
  int32 OnJoinResponse(struct message& msg);

  int32 LookupPeer(char8* pchHashKey, int32 len, enum transtype tt, void* (*callback)(void*, int32), void* pApp);
  int32 OnLookupPeerRequest(struct message& msg, char* pchIP, int32 port, transtype tt);
  int32 OnLookupPeerResponse(struct message& msg);

  int32 Set(char8* pchIP, uint16 port, enum transtype tt, struct nodeval& stnv, void* (*callback)(void*, int32), void* pApp);
  int32 Reset(char8* pchIP, uint16 port, enum transtype tt, struct nodeval& stnv, void* (*callback)(void*, int32), void* pApp);
  int32 OnSetRequest(struct message& msg, char* pchIP, int32 port, transtype tt);
  int32 OnResetRequest(struct message& msg, char* pchIP, int32 port, transtype tt);

  int32 GetDiagnostics(char8* pchIP, uint16 port, enum transtype tt, enum diag_type diagtype, void* (*callback)(void*, int32), void* pApp);
  int32 OnGetDiagnosticsResponse(struct message& msg);

  int32 OnTransactionTimeout(enum msgtype mtype, enum reqoritype ritype, string strtransid, char* pchIP, int32 port);

  int32 OnResponse(struct message& msg);

  void Disconnect();

};

#endif
