Chat API

API call to send messages to PlanetTogether users

Examples in this guide reference code from the APS Web Service Client Sample project that has a web service proxy configured. If you are just getting started with the APS Web Services APIs, please see our client sample.

API Function

The Chat API is used to share messages with PlanetTogether users in the collaboration window.

API Parameters

The Chat API uses the following 6 parameters:

  • Username (string) - the user's username performing the call
  • Password (string) - the user's related password. An empty string will be used if this parameter is not included in the request.
  • TimeoutDuration (TimeSpan) - the time to wait when trying to connect to Extra Services or attempting to get a data lock. If this parameter is not included in the request, a default value of 30 seconds will be used.
  • ScenarioId (long) - Id of the scenario.
  • RecipientName (string) - User to send the message to.
  • ChatMessage (string) - the message to send.

API Call

Once the typed Request is created the API call can be made using the following format:

//Sending a request
ApsWebServiceResponseBase resp = client.Chat(chatRequest);

API Request

This API request inherits from ApsWebScenarioRequest. Check out our KB article on the API Request Base classes to learn more: Basic API Structure

To use the API you must create a typed Request using the Request Data Contract. The related web client will use this Request to trigger the process.

  • Data Contract
[DataContract]
public class ChatRequest : ApsWebServiceScenarioRequest
{
[DataMember(IsRequired = true)]
public string RecipientName { get; set; }

[DataMember(IsRequired = true)]
public string ChatMessage { get; set; }
}

      API Request  Example

      //Create a chat request
      APSWebServiceRef.ChatRequest chatReuqest = new ChatRequest() {
      RecipientName = "John",
      Message = "Hello!"
      };

      //Request Base
      chatReuqest.UserName = username;
      chatReuqest.Password = pwd;
      chatReuqest.TimeoutDuration = TimeSpan.FromMinutes(5);

      //Scenario Request
      chatReuqest.ScenarioId = long.MinValue;

      API Response

      All API calls return a Response object to help determine the result of the call. Check out our Basic API Structure KB article for more information.

      Response Example

      //Sending a request
      start = DateTime.Now;
      ApsWebServiceResponseBase resp = client.Chat(chatReuqest);
      Console.WriteLine($"Response received after '{DateTime.Now.Subtract(start)}'");

      //Display results
      if (!a_response.Exception)
      {
      Trace($"Completed with Zero Errors");
      }
      else
      {
      Trace($"Completed with Errors");
      Trace(a_response.FullExceptionText);
      }