示例#1
0
        /// <summary>
        /// Creates a <see cref="T:OctoprintClient.OctoprintConnection"/>
        /// </summary>
        /// <param name="eP">The endpoint Address like "http://192.168.1.2/"</param>
        /// <param name="aK">The Api Key of the User account you want to use. You can get this in the user settings</param>

        public OctoprintConnectionUWP(string eP, string aK) : base(eP, aK)
        {
            Position = new OctoprintPos(this);
            Files    = new OctoprintFileTracker(this);
            Jobs     = new OctoprintJobTracker(this);
            Printer  = new OctoprintPrinter(this);

            WebSocket = new WebSocket(GetWebsocketurl());
            WebSocket.ConnectAsync();
            WebSocket.OnMessage += webSocket_OnMessage;
        }
示例#2
0
        /// <summary>
        /// Creates a <see cref="T:OctoprintClient.OctoprintConnection"/>
        /// </summary>
        /// <param name="eP">The endpoint Address like "http://192.168.1.2/"</param>
        /// <param name="aK">The Api Key of the User account you want to use. You can get this in the user settings</param>
        public OctoprintConnection(string eP, string aK)
        {
            SetEndPointDirty(eP);
            ApiKey   = aK;
            Position = new OctoprintPosTracker(this);
            Files    = new OctoprintFileTracker(this);
            Jobs     = new OctoprintJobTracker(this);
            Printers = new OctoprintPrinterTracker(this);
            //source = new CancellationTokenSource();
            //token = source.Token;
            var canceltoken = CancellationToken.None;

            WebSocket = new ClientWebSocket();
            WebSocket.ConnectAsync(new Uri("ws://" + EndPoint.Replace("https://", "").Replace("http://", "") + "sockjs/websocket"), canceltoken).GetAwaiter().GetResult();
        }