Skip to content
CaffeinatedRat edited this page Apr 3, 2013 · 9 revisions

Called during the instantiation of the WebSocketServices object, the constructor is responsible for initializing the object with user defined or default settings.

Method Signature

The following is the method signature:

CaffeinatedRat.Minecraft.WebSocketServices(parameters)

Parameters

The following parameters can be supplied to the constructor. To pass parameters to the constructor, see the example below. If you do not specify an optional parameter in the parameter collection, then the default value will be used.

wss = new CaffeinatedRat.Minecraft.WebSocketServices({
	websocketAddress: 'ws://localhost:25564',
	debug: true
});

websocketCheck

This is an optional parameter that indicates that the library will check for websocket support and throw the exception CaffeinatedRat.Minecraft.WebSocketServices.NotSupportedException if the browser does not support it. If this value is false then websocket check will be left to you.

  • Value: true or false
  • Default: true

websocketAddress (required)

The websocketAddress is a required parameter, without it the library will throw the exception CaffeinatedRat.Minecraft.WebSocketServices.InvalidAddressException. The websocketAddress can be any domain or ip address but must specify the websocket protocol.

Value: ws://your.domain.here.com

pingInterval

This parameter is used to determine the amount of time in milliseconds that the ping service will ping the WebSocketServer.

  • Value: 0 - 2147483647
  • Default: 15000 (milliseconds)

onlineInterval

This parameter is used to determine the amount of time in milliseconds that the online service will request the online information from the WebSocketServer.

  • Value: 0 - 2147483647
  • Default: 15000 (milliseconds)

debug

This parameter will enable logging to the console. Every service will write verbose information to the console. It is suggested that you keep this off unless you need to diagnose a problem.

  • Value: true or false
  • Default: false

imageServerURL

This parameter is used to indicate where the library will pull the Minecraft skin images. Use this parameter to specify a custom skin server, such as an image proxy. Since the current Minecraft skin server does not support CORS, you will have to have a custom image proxy in order to use the webgl skinprofile library.

forceDefaultSkin

This parameter will force the library to use a default skin for everyone and will not attempt to retrieve the skin from the image server.

  • Value: true or false
  • Default: false

defaultSkin

This parameter is a url or a dataurl of the default skin to use in conjunction with the forceDefaultSkin parameter.

  • Value: 'Your image's url or dataurl here.'
  • Default: Steve's skin.

imageSmoothing

This parameter determines what type of interpolation the browser will use when stretching the image to fit the canvas. If this parameter is true, then the browser will use a better quality interpolation beyond nearest-neighbor, else nearest-neighbor is used to preserve the pixel quality of Minecraft.

  • Value: true or false
  • Default: false

showLoadingImage

This parameter will determine if a loading image will be shown, while the data is being downloaded from the WebSocketServer. If your server takes a long time or there is a lot of data to load from the WebSocketServer then enable this feature.

  • Value: true or false
  • Default: false

loadingImage

This parameter is a url or a dataurl of the loading image to display in conjunction with the showLoadingImage parameter.

  • Value: 'Your image's url or dataurl here.'
  • Default: 'A loading image'

disableVersionMismatchWarning

This parameter is used to enable or disable the version mismatch warning. The version mismatch warning will be thrown if the client-side library is not the same version as the server-side plug-in.

  • Value: true or false
  • Default: true

Exceptions

The following exceptions are thrown by the constructor.

  • CaffeinatedRat.Minecraft.WebSocketServices.NotSupportedException
  • CaffeinatedRat.Minecraft.WebSocketServices.InvalidAddressException