Jump to content

Bug on API Client?


dalton5

Recommended Posts

dalton5

Hi,

 

I have an issue to authenticate on EmbyServer with EMby Api Client.

 

I do:

ApiClient client = new ApiClient(logger, Settings.Default.EmbyUrl, "myapikey", cryptoProvider);

I always have device which is null and an exception is raised.

 

After investigation it seems to come from BaseApiClient

 protected string AuthorizationParameter
        {
            get
            {
                if (string.IsNullOrEmpty(ClientName) && string.IsNullOrEmpty(DeviceId) && string.IsNullOrEmpty(DeviceName))
                {
                    return string.Empty;
                }

It tests DeviceId but it points to Properties Device.DeviceId and device is null and never set.

  /// <summary>
        /// Gets or sets the device id.
        /// </summary>
        /// <value>The device id.</value>
        public string DeviceId
        {
            get { return Device.DeviceId; }
        }

WHat am I doing wrong?

 

Is it a bug?

 

Thanks,

 

Link to comment
Share on other sites

dalton5

Ok thanks.

 

Where can I find the détails of the devices?

 

In my emby admin device page it's blank.

 

And in swagger I have the error, TypeError: Failed to fetch

 

Thanks,

Link to comment
Share on other sites

dalton5

Yes. Thanks. I am using the c# api.

 

FYI, the documentation is a little old and it's quite difficult to understand how everything is working. :)

 

But I would like to be able to receive all playback events from all the devices connected to my server.

 

How can I do that easily?

 

I do not want to select one device connected but all.

 

I thought it was possible by using the apikey token but it seems to be buggy..

 

Thanks,

Edited by dalton5
Link to comment
Share on other sites

Everything we've talked about up to this point is just about getting the library loaded and connecting to the server. None of what I've said will prevent you from doing what you want to do.

Link to comment
Share on other sites

dalton5

Ok. So is there an example on how to do this?

 

I have followed the instructions on API client .net github page and opened the web socket and when I am trying to raise the playback event nothing is raised.

 

Thanks

 

 

Envoyé de mon iPhone en utilisant Tapatalk

Link to comment
Share on other sites

dalton5

Yes and i CAN connect but i can't get events raised every time a playback command is sent to the server

 

 

Envoyé de mon iPhone en utilisant Tapatalk

Link to comment
Share on other sites

dalton5

Ok finally found the issue.

 

It's in the .net API. The response json arrives not full. I had to fix some stuff.

 

And now the playbackstart event is raised. Thanks for your help!

 

The fix:

 string jsonFull = "";

        /// <summary>
        /// Called when [message received].
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        protected void OnMessageReceived(byte[] bytes)
        {
            var json = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

            try
            {
                if (json.StartsWith("{\"MessageType"))
                    jsonFull = json.Replace("\0", string.Empty);
                else jsonFull = jsonFull + json.Replace("\0", string.Empty);
                JsonSerializer.DeserializeFromString<WebSocketMessage>(jsonFull);
                OnMessageReceived(jsonFull);
            }
            catch {

            }

            
        }
Edited by dalton5
Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...