初始化
通过配置参数登录服务器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using FBoxClientDriver;
using FBoxClientDriver.Contract;
using FBoxClientDriver.Impl;
namespace SDKDEMO
{
//配置参数
public class FBoxClientParameters
{
public static string ClientId { get; set; } = "ClientId";
public static string ClientSecret { get; set; } = "ClientSecret";
public static string UserName { get; set; } = "UserName";
public static string Password { get; set; } = "Password";
public static string IdServer { get; set; } = "https://account.flexem.com/core";
public static string MainServer { get; set; } = "http://fbox360.com";
public static string HdataServer { get; set; } = "http://fbhs1.fbox360.com";
}
public class FBoxDemo : IDisposable
{
private readonly IFBoxClientManager _fbox;
private readonly string boxNo = "300015050009"; // 以这个为例子
public FBoxDemo()
{
//创建对象并初始化
var provider =
new DefaultCredentialProvider(FBoxClientParameters.ClientId, FBoxClientParameters.ClientSecret,
FBoxClientParameters.UserName, FBoxClientParameters.Password);
_fbox = new FBoxClientManager(FBoxClientParameters.IdServer, FBoxClientParameters.MainServer,
FBoxClientParameters.HdataServer, provider, Guid.NewGuid().ToString("N"), null);
}
public void Dispose()
{
_fbox?.Dispose();
}
/// <summary>
/// 启动
/// </summary>
public void Start()
{
//初始化SDK,内部建立signalr连接对象,Restart只需全局执行一次。
_fbox.Restart().Wait();
}
}
class Program
{
static void Main(string[] args)
{
using (var fbox = new FBoxDemo())
{
//调用启动方法,内部建立signalr连接对象,Restart只需全局执行一次。
fbox.Start();
Console.ReadLine();
}
}
}
}
在创建IFBoxClientManager实例并初始化时,您需要提供一下参数:clientId
、clientsecret
、username
、password
、Id server
、App server
、和Hdata Server
username
、password
为FlexManager的账号、密码clientId
、clientsecret
为找销售申请的账号、密码Id server
、App server
、和Hdata Server
若公有云的话不变,私有云改为对应地址