本文整理汇总了C#中CallbackManager类的典型用法代码示例。如果您正苦于以下问题:C# CallbackManager类的具体用法?C# CallbackManager怎么用?C# CallbackManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallbackManager类属于命名空间,在下文中一共展示了CallbackManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PICSTokens
public PICSTokens(CallbackManager manager)
: base(manager)
{
manager.Register(new Callback<SteamApps.PICSTokensCallback>(OnPICSTokens));
Reload();
}
示例2: PICSChanges
public PICSChanges(CallbackManager manager)
: base(manager)
{
if (Settings.IsFullRun)
{
PreviousChangeNumber = 1; // Request everything
manager.Subscribe<SteamApps.PICSChangesCallback>(OnPICSChangesFullRun);
return;
}
manager.Subscribe<SteamApps.PICSChangesCallback>(OnPICSChanges);
using (var db = Database.GetConnection())
{
BillingTypeKey = db.ExecuteScalar<uint>("SELECT `ID` FROM `KeyNamesSubs` WHERE `Name` = 'root_billingtype'");
PreviousChangeNumber = db.ExecuteScalar<uint>("SELECT `ChangeID` FROM `Changelists` ORDER BY `ChangeID` DESC LIMIT 1");
Log.WriteInfo("PICSChanges", "Previous changelist was {0}", PreviousChangeNumber);
}
if (PreviousChangeNumber == 0)
{
Log.WriteWarn("PICSChanges", "Looks like there are no changelists in the database.");
Log.WriteWarn("PICSChanges", "If you want to fill up your database first, restart with \"FullRun\" setting set to 1.");
}
}
示例3: FreeLicense
public FreeLicense(CallbackManager manager)
: base(manager)
{
PackageRegex = new Regex("RemoveFreeLicense\\( ?(?<subid>[0-9]+), ?'(?<name>.+)' ?\\)", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture);
manager.Subscribe<SteamApps.FreeLicenseCallback>(OnFreeLicenseCallback);
}
示例4: PICSChanges
public PICSChanges(CallbackManager manager)
: base(manager)
{
if (Settings.IsFullRun)
{
PreviousChangeNumber = 1; // Request everything
manager.Register(new Callback<SteamApps.PICSChangesCallback>(OnPICSChangesFullRun));
return;
}
manager.Register(new Callback<SteamApps.PICSChangesCallback>(OnPICSChanges));
using (MySqlDataReader Reader = DbWorker.ExecuteReader("SELECT `ChangeID` FROM `Changelists` ORDER BY `ChangeID` DESC LIMIT 1"))
{
if (Reader.Read())
{
PreviousChangeNumber = Reader.GetUInt32("ChangeID");
Log.WriteInfo("PICSChanges", "Previous changelist was {0}", PreviousChangeNumber);
}
}
if (PreviousChangeNumber == 0)
{
Log.WriteWarn("PICSChanges", "Looks like there are no changelists in the database.");
Log.WriteWarn("PICSChanges", "If you want to fill up your database first, restart with \"FullRun\" setting set to 1.");
}
}
示例5: LogIn
static void LogIn()
{
steamClient = new SteamClient();
callbackManager = new CallbackManager(steamClient);
steamUser = steamClient.GetHandler<SteamUser>();
steamFriends = steamClient.GetHandler<SteamFriends>();
steamTrading = steamClient.GetHandler<SteamTrading>();
new Callback<SteamClient.ConnectedCallback>(OnConnect,callbackManager);
new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, callbackManager);
new Callback<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth, callbackManager);
new Callback<SteamClient.DisconnectedCallback>(OnDisconnected, callbackManager);
new Callback<SteamUser.AccountInfoCallback>(OnAccountInfo, callbackManager);
new Callback<SteamFriends.FriendMsgCallback>(OnChatMessage, callbackManager);
new Callback<SteamFriends.FriendsListCallback>(OnFriendInvite, callbackManager);
new Callback<SteamTrading.TradeProposedCallback>(OnTradeOffer, callbackManager);
new Callback<SteamTrading.SessionStartCallback>(OnTradeWindow, callbackManager);
new Callback<SteamTrading.TradeResultCallback>(OnTradeResult, callbackManager);
isRunning = true;
Console.WriteLine("Attempting to connect to steam...");
steamClient.Connect();
while(isRunning)
{
callbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
}
Console.ReadKey();
}
示例6: GameCoordinator
public GameCoordinator(uint appID, SteamClient steamClient, CallbackManager callbackManager)
{
// Map gc messages to our callback functions
GCMessageMap = new Dictionary<uint, Action<IPacketGCMsg>>
{
{ (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome, OnClientWelcome },
{ (uint)EGCItemMsg.k_EMsgGCUpdateItemSchema, OnItemSchemaUpdate },
{ (uint)EGCBaseMsg.k_EMsgGCSystemMessage, OnSystemMessage },
{ (uint)EGCBaseClientMsg.k_EMsgGCClientConnectionStatus, OnClientConnectionStatus },
{ (uint)4008 /* TF2's k_EMsgGCClientGoodbye */, OnClientConnectionStatus }
};
this.AppID = appID;
this.SteamClient = steamClient;
this.SteamGameCoordinator = SteamClient.GetHandler<SteamGameCoordinator>();
this.Name = string.Format("GC {0}", appID);
// Make sure Steam knows we're playing the game
Timer = new System.Timers.Timer();
Timer.Elapsed += OnTimerPlayGame;
Timer.Interval = TimeSpan.FromMinutes(5).TotalMilliseconds;
Timer.Start();
Timer = new System.Timers.Timer();
Timer.Elapsed += OnTimer;
callbackManager.Register(new Callback<SteamGameCoordinator.MessageCallback>(OnGameCoordinatorMessage));
}
示例7: SteamBot
public SteamBot(string newUser, string newPass)
{
// Bot user and password
user = newUser;
pass = newPass;
// create our steamclient instance
steamClient = new SteamClient( System.Net.Sockets.ProtocolType.Tcp );
// create the callback manager which will route callbacks to function calls
manager = new CallbackManager( steamClient );
// get the steamuser handler, which is used for logging on after successfully connecting
steamUser = steamClient.GetHandler<SteamUser>();
// get the steam friends handler, which is used for interacting with friends on the network after logging on
steamFriends = steamClient.GetHandler<SteamFriends>();
// register a few callbacks we're interested in
// these are registered upon creation to a callback manager, which will then route the callbacks
// to the functions specified
new Callback<SteamClient.ConnectedCallback>( OnConnected, manager );
new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager );
new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager );
// we use the following callbacks for friends related activities
new Callback<SteamUser.AccountInfoCallback>( OnAccountInfo, manager );
new Callback<SteamFriends.FriendsListCallback>( OnFriendsList, manager );
new Callback<SteamFriends.FriendMsgCallback> (OnFriendMessage, manager);
// initiate the connection
steamClient.Connect();
// Make sure the main loop runs
isRunning = true;
}
示例8: PICSTokens
public PICSTokens(CallbackManager manager)
: base(manager)
{
manager.Subscribe<SteamApps.PICSTokensCallback>(OnPICSTokens);
Reload();
}
示例9: Login
private static void Login()
{
steamClient = new SteamClient();
callBackManager = new CallbackManager(steamClient);
steamFriends = steamClient.GetHandler<SteamFriends>();
steamUser = steamClient.GetHandler<SteamUser>();
callBackManager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
callBackManager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedIn);
callBackManager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
callBackManager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
callBackManager.Subscribe<SteamFriends.FriendMsgCallback>(OnMsgRecieved);
callBackManager.Subscribe<SteamUser.AccountInfoCallback>(OnAccountInfo);
callBackManager.Subscribe<SteamFriends.FriendsListCallback>(OnFriendsList);
callBackManager.Subscribe<SteamFriends.FriendAddedCallback>(OnFriendAdded);
callBackManager.Subscribe<SteamFriends.PersonaStateCallback>(OnFriendPersonaChange);
SteamDirectory.Initialize().Wait();
steamClient.Connect();
isRunning = true;
while (isRunning)
{
callBackManager.RunWaitCallbacks(TimeSpan.FromSeconds(0.5));
}
Console.ReadKey();
}
示例10: GameCoordinator
public GameCoordinator(SteamClient steamClient, CallbackManager manager)
{
SessionMap = new Dictionary<uint, SessionInfo>();
// Map gc messages to our callback functions
MessageMap = new Dictionary<uint, Action<uint, IPacketGCMsg>>
{
{ (uint)EGCBaseClientMsg.k_EMsgGCClientConnectionStatus, OnConnectionStatus },
{ (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome, OnWelcome },
{ (uint)EGCItemMsg.k_EMsgGCUpdateItemSchema, OnItemSchemaUpdate },
{ (uint)EGCItemMsg.k_EMsgGCClientVersionUpdated, OnVersionUpdate },
{ (uint)EGCBaseMsg.k_EMsgGCSystemMessage, OnSystemMessage },
// TF2 specific messages
{ k_EMsgGCClientGoodbye, OnConnectionStatus },
{ (uint)EGCItemMsg.k_EMsgGCGoldenWrenchBroadcast, OnWrenchBroadcast },
{ k_EMsgGCTFSpecificItemBroadcast, OnItemBroadcast },
};
SteamGameCoordinator = steamClient.GetHandler<SteamGameCoordinator>();
SessionTimer = new Timer();
SessionTimer.Interval = TimeSpan.FromSeconds(30).TotalMilliseconds;
SessionTimer.Elapsed += OnSessionTick;
SessionTimer.Start();
manager.Subscribe<SteamGameCoordinator.MessageCallback>(OnGameCoordinatorMessage);
manager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);
manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
}
示例11: GCClient
public GCClient()
{
SteamClient = new SteamClient();
SteamClient.AddHandler( new SteamGames() );
CallbackManager = new CallbackManager( SteamClient );
SteamUser = SteamClient.GetHandler<SteamUser>();
SteamGameCoordinator = SteamClient.GetHandler<SteamGameCoordinator>();
SteamApps = SteamClient.GetHandler<SteamApps>();
SteamGames = SteamClient.GetHandler<SteamGames>();
SteamFriends = SteamClient.GetHandler<SteamFriends>();
new Callback<SteamClient.ConnectedCallback>( OnConnected, CallbackManager );
new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, CallbackManager );
new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, CallbackManager );
new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, CallbackManager );
new Callback<SteamApps.LicenseListCallback>( OnLicenseList, CallbackManager );
new Callback<SteamGameCoordinator.MessageCallback>( OnGCMessage, CallbackManager );
new JobCallback<SteamApps.AppOwnershipTicketCallback>( OnAppTicket, CallbackManager );
}
示例12: Steam
public Steam()
{
Client = new SteamClient();
User = Client.GetHandler<SteamUser>();
Apps = Client.GetHandler<SteamApps>();
Friends = Client.GetHandler<SteamFriends>();
UserStats = Client.GetHandler<SteamUserStats>();
CallbackManager = new CallbackManager(Client);
Client.AddHandler(new ReadMachineAuth());
new Connection(CallbackManager);
new PICSProductInfo(CallbackManager);
new PICSTokens(CallbackManager);
new LicenseList(CallbackManager);
new WebAuth(CallbackManager);
new FreeLicense(CallbackManager);
if (!Settings.IsFullRun)
{
new AccountInfo(CallbackManager);
new ClanState(CallbackManager);
new ChatMemberInfo(CallbackManager);
new GameCoordinator(Client, CallbackManager);
new Watchdog();
}
PICSChanges = new PICSChanges(CallbackManager);
DepotProcessor = new DepotProcessor(Client, CallbackManager);
IsRunning = true;
}
示例13: Main
static void Main( string[] args )
{
if ( args.Length < 2 )
{
Console.WriteLine( "SendMessage: No username and password specified!" );
return;
}
// exit gracefully if possible
Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
e.Cancel = true;
isRunning = false;
};
var url = "http://localhost:3131";
var host = new NancyHost(new Uri(url));
host.Start();
Console.WriteLine ("Server now running on: " + url);
// save our logon details
user = args[ 0 ];
pass = args[ 1 ];
manager = new CallbackManager( Steam3.SteamClient );
new Callback<SteamClient.ConnectedCallback>( OnConnected, manager );
new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager );
new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager );
new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, manager );
// we use the following callbacks for friends related activities
new Callback<SteamUser.AccountInfoCallback>( OnAccountInfo, manager );
new Callback<SteamFriends.FriendsListCallback>( OnFriendsList, manager );
new Callback<SteamFriends.PersonaStateCallback>( OnPersonaState, manager );
new Callback<SteamFriends.FriendAddedCallback>( OnFriendAdded, manager );
new Callback<SteamFriends.FriendMsgCallback>( OnMsgReceived, manager );
isRunning = true;
Console.WriteLine( "Connecting to Steam..." );
// initiate the connection
Steam3.SteamClient.Connect( false );
// create our callback handling loop
while ( isRunning )
{
// in order for the callbacks to get routed, they need to be handled by the manager
manager.RunWaitCallbacks( TimeSpan.FromSeconds( 1 ) );
}
Console.WriteLine( "Disconnecting from Steam..." );
Steam3.SteamUser.LogOff();
Steam3.SteamClient.Disconnect();
host.Stop();
host.Stop();
}
示例14: Login
public Login(SteamNerd steamNerd, CallbackManager manager)
{
_steamNerd = steamNerd;
manager.Subscribe<SteamClient.ConnectedCallback>(OnConnect);
manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnect);
manager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
manager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
manager.Subscribe<SteamUser.LoginKeyCallback>(OnLoginKey);
}
示例15: Main
static void Main( string[] args )
{
// install our debug listeners for this example
// install an instance of our custom listener
DebugLog.AddListener( new MyListener() );
// install a listener as an anonymous method
// this call is commented as it would be redundant to install a second listener that also displays messages to the console
// DebugLog.AddListener( ( category, msg ) => Console.WriteLine( "AnonymousMethod - {0}: {1}", category, msg ) );
// Enable DebugLog in release builds
DebugLog.Enabled = true;
if ( args.Length < 2 )
{
Console.WriteLine( "Sample4: No username and password specified!" );
return;
}
// save our logon details
user = args[ 0 ];
pass = args[ 1 ];
// create our steamclient instance
steamClient = new SteamClient();
// create the callback manager which will route callbacks to function calls
manager = new CallbackManager( steamClient );
// get the steamuser handler, which is used for logging on after successfully connecting
steamUser = steamClient.GetHandler<SteamUser>();
// register a few callbacks we're interested in
// these are registered upon creation to a callback manager, which will then route the callbacks
// to the functions specified
new Callback<SteamClient.ConnectedCallback>( OnConnected, manager );
new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager );
new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager );
new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, manager );
isRunning = true;
Console.WriteLine( "Connecting to Steam..." );
// initiate the connection
steamClient.Connect();
// create our callback handling loop
while ( isRunning )
{
// in order for the callbacks to get routed, they need to be handled by the manager
manager.RunWaitCallbacks( TimeSpan.FromSeconds( 1 ) );
}
}