/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.robotraconteur;

import java.util.*;

public class ServerContext {
  private transient long swigCPtr;
  private transient boolean swigCMemOwn;

  protected ServerContext(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(ServerContext obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void swigSetCMemOwn(boolean own) {
    swigCMemOwn = own;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        RobotRaconteurJavaJNI.delete_ServerContext(swigCPtr);
      }
      swigCPtr = 0;
    }
  }


//public delegate void ServerServiceListenerDelegate(ServerContext service, ServerServiceListenerEventType ev, object parameter);
public void setServiceAttributes(Map<String,Object> attributes)
{
  MessageElement m = new MessageElement("value",RobotRaconteurNode.s().packVarType(attributes));
  _SetServiceAttributes(m);

}

/*
public void AddServerServiceListener(ServerServiceListenerDelegate listener)
{
  ServerServiceListenerDirectorJava d = new ServerServiceListenerDirectorJava(this, listener);
  d.objectheapid = RRObjectHeap.addObject(d);

  _AddServerServiceListener(d);
}*/

public void releaseServicePath(String path)
{
	_ReleaseServicePath(path);
}

public void releaseServicePath(String path, long[] endpoints)
{
	vectoruint32 o=new vectoruint32();
	for(int i=0; i<endpoints.length; i++)
	{
		o.add(endpoints[i]);
	}

	_ReleaseServicePath(path,o);
}


  public static String getCurrentServicePath() {
    return RobotRaconteurJavaJNI.ServerContext_getCurrentServicePath();
  }

  public void _ReleaseServicePath(String path) {
    RobotRaconteurJavaJNI.ServerContext__ReleaseServicePath__SWIG_0(swigCPtr, this, path);
  }

  private void _ReleaseServicePath(String path, vectoruint32 endpoints) {
    RobotRaconteurJavaJNI.ServerContext__ReleaseServicePath__SWIG_1(swigCPtr, this, path, vectoruint32.getCPtr(endpoints), endpoints);
  }

  public static ServerContext getCurrentServerContext() {
    long cPtr = RobotRaconteurJavaJNI.ServerContext_getCurrentServerContext();
    return (cPtr == 0) ? null : new ServerContext(cPtr, true);
  }

  public void kickUser(String username) {
    RobotRaconteurJavaJNI.ServerContext_kickUser(swigCPtr, this, username);
  }

  private void _AddServerServiceListener(ServerServiceListenerDirector listener) {
    RobotRaconteurJavaJNI.ServerContext__AddServerServiceListener(swigCPtr, this, ServerServiceListenerDirector.getCPtr(listener), listener);
  }

  private void _SetServiceAttributes(MessageElement attributes) {
    RobotRaconteurJavaJNI.ServerContext__SetServiceAttributes(swigCPtr, this, MessageElement.getCPtr(attributes), attributes);
  }

  public void requestObjectLock(String servicepath, String username) {
    RobotRaconteurJavaJNI.ServerContext_requestObjectLock(swigCPtr, this, servicepath, username);
  }

  public void requestClientObjectLock(String servicepath, String username, long endpoint) {
    RobotRaconteurJavaJNI.ServerContext_requestClientObjectLock(swigCPtr, this, servicepath, username, endpoint);
  }

  public void releaseObjectLock(String servicepath, String username, boolean override_) {
    RobotRaconteurJavaJNI.ServerContext_releaseObjectLock(swigCPtr, this, servicepath, username, override_);
  }

  public String getObjectLockUsername(String servicepath) {
    return RobotRaconteurJavaJNI.ServerContext_getObjectLockUsername(swigCPtr, this, servicepath);
  }

  public RobotRaconteurNode getNode() {
    long cPtr = RobotRaconteurJavaJNI.ServerContext_getNode(swigCPtr, this);
    return (cPtr == 0) ? null : new RobotRaconteurNode(cPtr, true);
  }

  public vectorstring getExtraImports() {
    return new vectorstring(RobotRaconteurJavaJNI.ServerContext_getExtraImports(swigCPtr, this), true);
  }

  public void addExtraImport(String import_) {
    RobotRaconteurJavaJNI.ServerContext_addExtraImport(swigCPtr, this, import_);
  }

  public boolean removeExtraImport(String import_) {
    return RobotRaconteurJavaJNI.ServerContext_removeExtraImport(swigCPtr, this, import_);
  }

  public vectorstring getCandidateConnectionURLs() {
    return new vectorstring(RobotRaconteurJavaJNI.ServerContext_getCandidateConnectionURLs(swigCPtr, this), true);
  }

  public void printCandidateConnectionURLs() {
    RobotRaconteurJavaJNI.ServerContext_printCandidateConnectionURLs(swigCPtr, this);
  }

  public void logCandidateConnectionURLs(LogLevel level) {
    RobotRaconteurJavaJNI.ServerContext_logCandidateConnectionURLs__SWIG_0(swigCPtr, this, level.swigValue());
  }

  public void logCandidateConnectionURLs() {
    RobotRaconteurJavaJNI.ServerContext_logCandidateConnectionURLs__SWIG_1(swigCPtr, this);
  }

}
