• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.umass.lastfm.Session的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Session类属于de.umass.lastfm包,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: scrobble

import de.umass.lastfm.Session; //导入依赖的package包/类
public List<ScrobbleResult> scrobble(Session session) throws IOException {
	File file = new File(cacheDir, SUBMISSIONS_FILE);
	List<ScrobbleResult> result = new ArrayList<ScrobbleResult>();
	if (file.exists()) {
		BufferedReader r = new BufferedReader(new FileReader(file));
		List<ScrobbleData> list = new ArrayList<ScrobbleData>(50);
		String line;
		while ((line = r.readLine()) != null) {
			ScrobbleData d = decodeScrobbleData(line);
			list.add(d);
			if (list.size() == 50) {
				result.addAll(Track.scrobble(list, session));
				list.clear();
			}
		}
		if (list.size() > 0)
			result.addAll(Track.scrobble(list, session));
		r.close();
		FileWriter w = new FileWriter(file);
		w.close();
	}
	return result;
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:24,代码来源:FileSystemCache.java


示例2: getSession_setsSessionOnSuccess

import de.umass.lastfm.Session; //导入依赖的package包/类
@Test
public void getSession_setsSessionOnSuccess() {
  String token = "token";
  String sessionKey = "sessionKey";

  when(lastfmApi.getSession(any(), any(), any()))
      .thenReturn(Session.createSession(API_KEY, API_SECRET, sessionKey));
  AuthResult expectedAuthResult = AuthResult.builder().sessionKey(sessionKey).build();

  client = new LastfmClient(lastfmApi, caller, "test");
  client.getSession(token, callback);

  assertThat(client.isAuthenticated()).isTrue();
  verify(lastfmApi).getSession(eq(token), eq(API_KEY), eq(API_SECRET));
  verify(callback).handleMessage(argThat(message -> expectedAuthResult.equals(message.obj)));
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:17,代码来源:LastfmClientTest.java


示例3: scrobble

import de.umass.lastfm.Session; //导入依赖的package包/类
public List<ScrobbleResult> scrobble(Session session) throws IOException {
    File file = new File(cacheDir, SUBMISSIONS_FILE);
    List<ScrobbleResult> result = new ArrayList<ScrobbleResult>();
    if (file.exists()) {
        BufferedReader r = new BufferedReader(new FileReader(file));
        List<ScrobbleData> list = new ArrayList<ScrobbleData>(50);
        String line;
        while ((line = r.readLine()) != null) {
            ScrobbleData d = decodeScrobbleData(line);
            list.add(d);
            if (list.size() == 50) {
                result.addAll(Track.scrobble(list, session));
                list.clear();
            }
        }
        if (list.size() > 0)
            result.addAll(Track.scrobble(list, session));
        r.close();
        FileWriter w = new FileWriter(file);
        w.close();
    }
    return result;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:24,代码来源:FileSystemCache.java


示例4: Lastfm

import de.umass.lastfm.Session; //导入依赖的package包/类
public Lastfm(Context context) {
    super(context);
    mContext = context;
    Resources res = context.getResources();

    API_KEY = res.getString(R.string.lastfm_api_key);
    API_SECRET = res.getString(R.string.lastfm_api_secret);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mAccessKey = mPrefs.getString("lastfm_access_key", null);
    mUserName = mPrefs.getString("lastfm_user_name", null);

    //if username and key not null -> recreate the lastfm session
    if(mAccessKey != null) {
        mSession = Session.createSession(API_KEY, API_SECRET, mAccessKey);
    }

    String ua = res.getString(R.string.user_agent);

    mLastfm = Caller.getInstance();
    mLastfm.setUserAgent(ua);
    mLastfm.setCache(null);
    mLastfm.setDebugMode(true);
}
 
开发者ID:jvanhie,项目名称:discogsscrobbler,代码行数:24,代码来源:Lastfm.java


示例5: login

import de.umass.lastfm.Session; //导入依赖的package包/类
@ActionMethod(Actions.LOGIN_ID)
public void login(User user) {
	String username = user.getUsername();
	String password = user.getPassword();
	try {
		Session session = lastfmAuthenticator.login(username, password);
		if (session != null) {
			user.setSession(session);
			configurator.getControlEngine().set(Model.CURRENT_USER, user, null);
			configurator.getControlEngine().fireEvent(Events.LOGGED, new ValueEvent<User>(user));
		} else {
			configurator.getControlEngine().fireEvent(Events.LOGIN_FAILED);
		}
	} catch (IOException ioe) {	
		log.error(ioe, ioe);
		configurator.getControlEngine().fireEvent(Events.LOGIN_FAILED);
	}
}
 
开发者ID:josdem,项目名称:jmetadata,代码行数:19,代码来源:LoginController.java


示例6: handshake

import de.umass.lastfm.Session; //导入依赖的package包/类
/**
 * Performs a web-service handshake.
 *
 * @param session An authenticated Session.
 * @return the status of the operation
 * @throws IOException on I/O errors
 * @see de.umass.lastfm.Authenticator
 */
public ResponseStatus handshake(Session session) throws IOException {
	long time = System.currentTimeMillis() / 1000;
	String auth = md5(session.getSecret() + time);
	String url = String
			.format("%s?hs=true&p=1.2.1&c=%s&v=%s&u=%s&t=%s&a=%s&api_key=%s&sk=%s", handshakeUrl, clientId,
					clientVersion, user, time, auth, session.getApiKey(), session.getKey());
	return performHandshake(url);
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:17,代码来源:Scrobbler.java


示例7: doInBackground

import de.umass.lastfm.Session; //导入依赖的package包/类
@Override
protected AuthResult doInBackground(String... params) {
  String token = params[0];

  Session session = api.getSession(token, API_KEY, API_SECRET);
  if (session != null) {
    return AuthResult.builder().sessionKey(session.getKey()).build();
  }

  de.umass.lastfm.Result result = caller.getLastResult();
  AuthResult.Builder authResultBuilder = AuthResult.builder();
  int httpErrorCode = result.getHttpErrorCode();
  int errorCode = result.getErrorCode();
  String errorMessage = result.getErrorMessage();

  if (httpErrorCode > -1) {
    authResultBuilder.httpErrorCode(httpErrorCode);
  }

  if (errorCode > -1) {
    authResultBuilder.errorCode(errorCode);
  }

  if (errorMessage != null) {
    authResultBuilder.error(errorMessage);
  }

  return authResultBuilder.build();
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:30,代码来源:LastfmClient.java


示例8: isAuthorized

import de.umass.lastfm.Session; //导入依赖的package包/类
public boolean isAuthorized(){
	if(session == null){
		if(sessionKey == null || username == null)
			return false;
		session = Session.createSession(key, secret, sessionKey, username, false);
	}
	
	return true;	
}
 
开发者ID:helderm,项目名称:songseeker,代码行数:10,代码来源:LastfmComm.java


示例9: handshake

import de.umass.lastfm.Session; //导入依赖的package包/类
/**
 * Performs a web-service handshake.
 *
 * @param session An authenticated Session.
 * @return the status of the operation
 * @throws IOException on I/O errors
 * @see de.umass.lastfm.Authenticator
 */
public ResponseStatus handshake(Session session) throws IOException {
    long time = System.currentTimeMillis() / 1000;
    String auth = md5(session.getSecret() + time);
    String url = String
            .format("%s?hs=true&p=1.2.1&c=%s&v=%s&u=%s&t=%s&a=%s&api_key=%s&sk=%s", handshakeUrl, clientId,
                    clientVersion, user, time, auth, session.getApiKey(), session.getKey());
    return performHandshake(url);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:17,代码来源:Scrobbler.java


示例10: setSession

import de.umass.lastfm.Session; //导入依赖的package包/类
private void setSession(String sessionKey) {
  session = Session.createSession(API_KEY, API_SECRET, sessionKey);
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:4,代码来源:LastfmClient.java


示例11: UpdateNowPlayingTask

import de.umass.lastfm.Session; //导入依赖的package包/类
public UpdateNowPlayingTask(LastfmApi api, Session session, Handler.Callback callback) {
  this.api = api;
  this.session = session;
  this.callback = callback;
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:6,代码来源:LastfmClient.java


示例12: ScrobbleTracksTask

import de.umass.lastfm.Session; //导入依赖的package包/类
ScrobbleTracksTask(LastfmApi api, Session session, Handler.Callback callback) {
  this.api = api;
  this.callback = callback;
  this.session = session;
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:6,代码来源:LastfmClient.java


示例13: GetTrackInfoTask

import de.umass.lastfm.Session; //导入依赖的package包/类
public GetTrackInfoTask(Session session, Handler.Callback callback) {
  this.session = session;
  this.callback = callback;
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:5,代码来源:LastfmClient.java


示例14: scrobble

import de.umass.lastfm.Session; //导入依赖的package包/类
/**
 * @see Track#scrobble(List, Session)
 */
public List<ScrobbleResult> scrobble(List<ScrobbleData> scrobbleData, Session session) {
  return Track.scrobble(scrobbleData, session);
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java


示例15: updateNowPlaying

import de.umass.lastfm.Session; //导入依赖的package包/类
/**
 * @see Track#updateNowPlaying(String, String, Session)
 */
public ScrobbleResult updateNowPlaying(String artistName, String trackName, Session session) {
  return Track.updateNowPlaying(artistName, trackName, session);
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java


示例16: getSession

import de.umass.lastfm.Session; //导入依赖的package包/类
/**
 * @see Authenticator#getSession(String, String, String)
 */
public Session getSession(String token, String apiKey, String secret) {
  return Authenticator.getSession(token, apiKey, secret);
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java


示例17: updateScrobbling

import de.umass.lastfm.Session; //导入依赖的package包/类
private void updateScrobbling() {
	if(musicPlayer.isActive() == false) {
		return;
	}
	if(!preference.getBoolean(getString(R.string.pref_lastfm_scrobbling), false))
		return;

	checkState(musicPlayer.getCurrentTrack() != null);
		
	Thread t = new Thread(new Runnable(){
		Track track = musicPlayer.getCurrentTrack();
		
		public void run() {	
			Session session = null;
			try {
				session = Authenticator.getMobileSession(
						preference.getString(getString(R.string.pref_lastfm_username), ""),
						preference.getString(getString(R.string.pref_lastfm_pwd), ""), 
						lastFM_key, lastFM_secret);
				
			} catch (de.umass.lastfm.CallException ex) {
				LOGGER.warn("de.umass.lastfm.CallException: {}",  ex.getMessage());
			}
			if(session == null)
			{
				//					LOGGER.debug("Could not log in");
				Looper.prepare();
				Toast.makeText(getBaseContext(),SonarflowApplication.getAppContext().getString(R.string.could_not_log_in), Toast.LENGTH_SHORT).show();
				Looper.loop();
				return;
			}
			try {
				Thread.sleep(30000);
			} catch (InterruptedException e1) {
				LOGGER.debug("Could not sleep");
			}

			if(track == musicPlayer.getCurrentTrack() && musicPlayer.isPlaying())
			{
				int now = (int)(System.currentTimeMillis()/1000);
				try{
					ScrobbleResult result = de.umass.lastfm.Track.scrobble(
							track.getArtistName(), track.getName(), now, session);
					if(result.isSuccessful() && !result.isIgnored())
					{
						Looper.prepare();
						Toast.makeText(getBaseContext(),SonarflowApplication.getAppContext().getString(R.string.current_song_scrobbled)  , Toast.LENGTH_SHORT).show();
						Looper.loop();
					}}
				catch(Exception e){
					Looper.prepare();
					LOGGER.error(e.getMessage());
					Toast.makeText(getBaseContext(), SonarflowApplication.getAppContext().getString(R.string.problem_with_scrobbling) , Toast.LENGTH_SHORT).show();
					Looper.loop();
				}
			}
		}
	});
	t.start();
}
 
开发者ID:spectralmind,项目名称:sonarflow-android,代码行数:61,代码来源:PlayerService.java


示例18: ScrobbleTask

import de.umass.lastfm.Session; //导入依赖的package包/类
public ScrobbleTask(Metadata metadata, Session session) {
	this.metadata = metadata;
	this.session = session;
}
 
开发者ID:josdem,项目名称:jmetadata,代码行数:5,代码来源:ScrobblerHelper.java


示例19: getSession

import de.umass.lastfm.Session; //导入依赖的package包/类
public Session getSession(String username, String password) {
	return Authenticator.getMobileSession(username, password, Auth.KEY, Auth.SECRET);
}
 
开发者ID:josdem,项目名称:jmetadata,代码行数:4,代码来源:AuthenticatorHelper.java


示例20: scrobble

import de.umass.lastfm.Session; //导入依赖的package包/类
public ScrobbleResult scrobble(String artist, String title, int time, Session session) {
	return Track.scrobble(artist, title, time, session);
}
 
开发者ID:josdem,项目名称:jmetadata,代码行数:4,代码来源:LastFMTrackHelper.java



注:本文中的de.umass.lastfm.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CorefCoreAnnotations类代码示例发布时间:2022-05-22
下一篇:
Java BlockHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap